Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    Adelaide, South Australia, Australia
    Posts
    146
    Thanks
    5
    Thanked 5 Times in 5 Posts

    Setting AutoText dialog to look in template (Office 2000 or higher)

    I have a client that ALWAYS saves their AutoText into a custom global template. (The user who creates and modifies the AutoText is always the first user to start Word, and therefore doesn't have a problem with control of the global template.) However, for every new session of Word, she has to remember that the first time she saves an AutoText entry, she has to change the Look In entry to point to the global template.

    I'm not aware of any setting in Word that will change this default, so have tried to change it programmatically. I have a workaround that I can use if necessary, but would like to know if there is any way that I can simply set it through Dialogs(wdDialogEditAutoText).Show. The arguments listed for this dialog box include Context, but the (un)Help(ful) file doesn't provide any more information, and whether I try to point the context to a text string (the template name) or a template object, I get a Type Mismatch error.

    Does anyone know whether (a) this can be done, ([img]/forums/images/smilies/cool.gif[/img] Context is the correct argument and what data type I should be using?

    Failing a usable answer to the above, I know I can create a routine that will ask for the AutoText entry (defaulting to selected text) and name, and save to the global template, but would probably need to include a list of the existing entries in the dialog box, so would rather not reinvent the wheel if there's a simpler alternative.

    Thanks!

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Setting AutoText dialog to look in template (Office 2000 or higher)

    According to my old book on WordBasic in Word 6 for Windows... Context is a number, where 0 = Normal.dot, 1 = "Active" Template, and after that it is said to follow the order set in the Templates and Add-Ins dialog. Hmmm... this should work, but it doesn't; the new entries all end up in the template you last made active in the dialog.
    <pre>Sub TestAT()
    Dim intCount As Integer
    For intCount = 0 To Templates.Count - 1
    With Dialogs(wdDialogEditAutoText)
    .Context = intCount
    .Name = "TestAT" & CStr(intCount)
    .Add = True
    .Execute ' Gives error on last two templates
    End With
    Next
    End Sub</pre>

    Next idea??

  3. #3
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    Adelaide, South Australia, Australia
    Posts
    146
    Thanks
    5
    Thanked 5 Times in 5 Posts

    Re: Setting AutoText dialog to look in template (Office 2000 or higher)

    Hadn't thought of going and digging up my old Word 6 manual!

    I tried your code, having added the template to my Startup folder. This meant that my Normal template should be 0, and also 1 as the attached template for the new blank document I had open; the three global templates should then have been 2, 3 and 4.

    When I ran the code, as you'd indicated, it worked for 0, 1 and 2, but gave an error when it got to 3. However, I also found that all three AutoText entries were stored in the Normal template, and none of them when into any global template.

    I then noticed that, although I was working in a blank document based on Normal.dot, and there were three templates in Startup which were all showing as active in the Templates and Add-ins dialog, when I went to Insert AutoText only Normal.dot and one of the global templates showed on the list. The global template was the only one that already contains AutoText.

    I disabled the other two templates, and when I ran the code again, it only looped twice - didn't even pick up the third template in the count. That template is the second on the list in Templates and Add-ins, although the only one that was checked.

    I'd never noticed before that Insert AutoText doesn't display global templates that don't already contain AutoText. I think this whole exercise has left me with more questions than answers, but I appreciate your input nevertheless!

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •