Autotext problem

W

WayneBurrows

Hi

Word 2003

I have a macro that I have been using for months without serious
incident then suddenly today it has stopped working giving an error.

I have a table that I insert via autotext.

I select some text and run a macro and the selected text is formated
and inserted into the table.

The autotext insertion is not working giving an error 5941 The
requested member of the collection does not exist.

It stops on this line

ActiveDocument.AttachedTemplate.AutoTextEntries("MyTable").Insert
Where:=oRng

The autotext entry "MyTable" works fine when i insert it manually.

Any ideas?

Thanks
 
J

Jay Freedman

Hi Wayne,

If the MyTable entry exists, but you're getting the 5941 error, then
the most reasonable explanation is that the entry is in some template
other than ActiveDocument.AttachedTemplate.

With that document open, first open the Insert > AutoText > AutoText
dialog and use the Look In dropdown to find out which template the
entry is in. Ignore the "All active templates" and look only at the
ones that are specific templates.

Then look in the Tools > Templates and Add-Ins dialog to find out
which template is the attached template (the one in the Document
Template box). Alternatively, in the VBA editor, press Ctrl+G to open
the Immediate window, enter the line

?ActiveDocument.AttachedTemplate.FullName

and press Enter.

If the attached template isn't the same as the one that contains the
AutoText entry, you can (a) attach the right template, (b) copy the
AutoText entry to the other template, or (c) modify the macro to make
sure the right template gets loaded.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
W

WayneBurrows

Hi Wayne,

If the MyTable entry exists, but you're getting the 5941 error, then
the most reasonable explanation is that the entry is in some template
other than ActiveDocument.AttachedTemplate.

With that document open, first open the Insert > AutoText > AutoText
dialog and use the Look In dropdown to find out which template the
entry is in. Ignore the "All active templates" and look only at the
ones that are specific templates.

Then look in the Tools > Templates and Add-Ins dialog to find out
which template is the attached template (the one in the Document
Template box). Alternatively, in the VBA editor, press Ctrl+G to open
the Immediate window, enter the line

?ActiveDocument.AttachedTemplate.FullName

and press Enter.

If the attached template isn't the same as the one that contains the
AutoText entry, you can (a) attach the right template, (b) copy the
AutoText entry to the other template, or (c) modify the macro to make
sure the right template gets loaded.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ:http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.











- Show quoted text -

Thanks

It appears somehow the Autotext must have been deleted from one
template and another with the same name inserted into another template
that was open.

Anyway all sorted now. In fact I managed to get it working by copying
the macro into a blank template before i read this reply and creating
a new document based on this new template.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top