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

    F3 doesn't insert AutoText from current template

    I am working at a site that has a number of PCs running Word 2000 (yes, I know, they're going to upgrade soon). There is a large number of Word templates, which are selected, opened and automated using VBA.

    Some of these templates insert AutoText that is stored within the relevant template (as opposed to a global template). The template text contains the names of a number of AutoText entries, and depending on selections in a dialog box, the AutoText names are deleted if not required, or expanded to the full entries using the Selection.Range.InsertAutoText command, which has worked for some time with no difficulty.

    Recently, however, some (but not all) PCs get a run-time error (5906 - The range does not specify a known AutoText entry) when the first InsertAutoText command is encountered. I have manually opened a document based on the template, gone to any of the listed AutoText entries and tapped F3; on the PCs that get the run-time error, the AutoText is not inserted, and the Status Bar shows the message "The specified text is not a valid AutoText name. Use Insert AutoText to create AutoText entries."; on the PCs that don't get the run-time error, F3 works as expected and the AutoText name is replaced by the full entry.

    If, on one of the PCs giving the error, I use the Insert AutoText menu steps, I can find the AutoText name and insert the full entry. If I close the template, the AutoText name is no longer available on the Insert AutoText list, thus eliminating the possibility that there is a duplicate AutoText name somewhere in a global template.

    I get the same results if I actually open the template, as when I open a document based on the template.

    If I key in the name of one of the AutoText entries in Normal.dot, F3 works exactly as I expect it to on all PCs. So the problem only seems to apply to AutoText stored in the current template.

    Some of the PCs displaying the problem are Word 2000 (9.0.6926 SP-3) and some of those that work OK are Word 2000 (9.0.3821 SR-1). Bingo! I thought I had identified the problem. Until I went to a PC where it works and found it was identical to those that don't work (ie 9.0.6926 SP-3). At that point I decided not go to go every PC in the 4 floors of the office until determining whether anyone has encountered this problem and knows of some setting I need to fix on the recalcitrant PCs.

    I have looked at Tools, Customize, Keyboard... and F3 is definitely allocated to InsertAutoText (as is Alt+Ctrl+V, which is doing exactly the same as F3 and the VBA InsertAutoText command on the problem PCs) (and I checked both ways - looked at InsertAutoText to see what was listed, then tried allocating F3 and Alt+Ctrl+V to something else to check that it told me what they were currently allocated to). I have checked the Compatibility options, checked that they all have the same settings in Tools Options, File Locations and Tools, Templates and Add-ins, and that they all have the same generic AutoText (not those causing the problems) in their Normal.dot files.

    Now, I know I can fix the automation problem by picking up the word immediately preceding the insertion point, storing it in a variable such as "ThisAutoTextName" and substituting "NormalTemplate.AutoTextEntries(ThisAutoTextNa me). Insert Where:= Selection.Range" for "Selection.Range.InsertAutoText". However, this would need to be done in several places in a reasonably large number of templates, and with an impending upgrade of the software, and accompanying full review of all the templates, it's an exercise I'd be happy to avoid if I can find out the reason why some of the PCs in this site work fine, and adjust the offending PCs accordingly.

    Thanks and regards
    Alison C
    (really sorry they no longer have the banging-your-head-on-a-brick-wall smiley)

  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
    I think this is affected by the "Look in" setting in the Insert > AutoText dialog (the location of the dialog differs between versions).

    If I change the setting from "All templates" to a template that does not contain the AutoText entry, then the Range.InsertAutoText method fails.

    Problem is, I can't find any programmatic solution. The documentation for the old EditAutoText dialog implies that you could set that drop-down using the Content argument in WordBasic, but it doesn't actually seem to work in VBA and in any event, "All templates" was never an option in WordBasic.

    So other than SendKeys, I think the user may have to "fix" that dialog manually. I suppose you could display it for fixing.

    (Note, to test in Word 2007, I'm using this macro to display the old dialog:

    Code:
    Sub OldAutotext()
    Word.Dialogs(wdDialogEditAutoText).Show
    End Sub
    )

    Old thread on futility of trying to program this dialog: Setting AutoText dialog to look in template (Office 2000 or higher) | Windows Secrets Lounge.

  3. #3
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    Adelaide, South Australia, Australia
    Posts
    146
    Thanks
    5
    Thanked 5 Times in 5 Posts
    How embarrassing! The post you redirected me to was an old one of mine, which I had forgotten about. In my defence, it was asked in a completely different context, but I still should have remembered it.

    I fixed the problem by getting VBA to pick up the text string immediately to the left of the cursor and get the AutoText that way. We decided to do it for the templates we know are in regular use, and I can paste the code fragment into any other template in the future (it wasn't big enough to be worth creating a separate routine).

    Still very annoying that we can't just change the Look In setting programmatically, but I guess that's Microsoft's idea of progress!

    And thanks for getting back to me - sorry I didn't acknowledge your response sooner.

    Cheers

    AlisonC

Posting Permissions

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