• F3 doesn’t insert AutoText from current template

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » F3 doesn’t insert AutoText from current template

    Author
    Topic
    #477485

    [INDENT]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(ThisAutoTextName). 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) [/INDENT]

    Viewing 0 reply threads
    Author
    Replies
    • #1285754

      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.

      • #1289311

        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

    Viewing 0 reply threads
    Reply To: F3 doesn’t insert AutoText from current template

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: