Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Brisbane, Australia
    Posts
    245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Attached Template AutoText Problem (VBA/Word/97)

    I am having a problem with some code that was working and has stopped. Maybe I am missing something obvious but this is the scenario.

    MS Word 97 starts with a template XYZ.dot stored in C:Program FilesMicrosoft OfficeOfficeStartup folder. (It contains all code, AutoText, custom toolbars, etc.) Code is run from the custom toolbar buttons each creating a new document based on a relevant template stored in the C:Program FilesMicrosoft OfficeTemplates folder.

    The following code WAS working but some assigned keyboard shortcuts gave up and so to clean up the XYZ.dot template I recreated it and copied all the code, AutoText, custom toolbars, etc. using the Organizer faithfully copying all across to the new copy of XYZ.dot.

    An experienced user then noted that the keyboard shortcuts were not working. I deleted all four, recreated them and they worked, even though they appear to be exactly as they were. Now the following code is not working for adding some information to a Memo. It uses a bookmark (it exists in the copy of the Memo.dot) and an AutoText entry (from the globally loaded XYZ.dot).

    <pre>Public Sub MAIN()
    ActiveDocument.Bookmarks("res").Select
    ActiveDocument.AttachedTemplate = "C:Program FilesMicrosoft OfficeOfficeStartupXYZ.dot"
    ActiveDocument.AttachedTemplate.AutoTextEntries("r esponse").Insert _
    where:=Selection.Range, RichText:=True
    ActiveDocument.Bookmarks("Start").Select
    End Sub</pre>

    This brings up the error " Run-time error '438' Object doesn't support this method or property "

    Any suggestions?

    Leigh

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Attached Template AutoText Problem (VBA/Word/97)

    Why is the add in also the attached template? Surely you only need it once and not twice.

    The error message appears to be saying that something is missing. Which line the error comes up on is the key. Try stepping through the macro to see which line is the stumbling block. The first line is looking for a bookmark, the second for an autotext entry and the third for another bookmark - one of these is missing.

    If you attach the XYZ.dot only to get at the autotext entry, you may prefer to get that from the template when it is an add in. This link will show you how.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Brisbane, Australia
    Posts
    245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Attached Template AutoText Problem (VBA/Word/97)

    Thanks Andrew, your pointer to that post solved the problem. Following your suggestion, the code stopped when inserting the "response" AutoText entry although it was listed in the AutoText entries under the Tools | AutoCorrect... | AutoText listing. Strange!

    The two references in the code to AttachedTemplate were changed to the following line of code:
    <pre>Templates("C:Program FilesMicrosoft OfficeOfficeStartupXYZ.dot") _
    .AutoTextEntries("response").Insert Where:=Selection.Range, RichText:=True</pre>

    Problem solved. It seems that the original code did not specifically reference the XYZ.dot template when it looked like it was.

  4. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Attached Template AutoText Problem (VBA/Word/97)

    I think the problem was because you had the template loaded twice - once as the attached template and once as an add-in. I am guessing that the add-in has taken precedence and Word won't let you get at the attached template autotext as a result.

    To avoid the confusion don't bother attaching the template unless you need it for other reasons in which case, don't make the template an add-in.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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