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).

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.

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.

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.