F
frank
I'm trying to create a template file that I can distribute to other users at
my company. What they want is to be able to push a button and a section
break will be inserted at the top of the document and a form will be inserted
above the break. I have created the code to do it. I saved the form
information under an AutoText Entry inside the template file (Form.dot). I
copied the form.dot to the startup folder where the other template files are
located. I can see the autotext entry in Tools/Autocorrect/Autotext when I
launch word. The Autotext entry (the actual form) can be inserted manually,
but when I try to insert it using VBA code it can't seem to find the Autotext
entry. I think I need to make a more detailed reference to it.
With the form.dot file located in the startup folder, I launch a blank word
file and when I start the macro it says:
Runtime error: 5941
The requested member of the collection does not exist
I can see the Autotext entry when I click on Tools/Autocorrect/Autotext, but
apparently the code is not calling it out. Here is the code I am using to
retrieve the autotext entry from the form.dot file located in the startup
folder and insert it into the current cursor position:
Application.DisplayAutoCompleteTips = True
With AutoCorrect
.CorrectInitialCaps = True
.CorrectSentenceCaps = True
.CorrectDays = True
.CorrectCapsLock = True
.ReplaceText = True
.ReplaceTextFromSpellingChecker = True
.CorrectKeyboardSetting = False
End With
ActiveDocument.AttachedTemplate.AutoTextEntries("Form").Insert Where _
:=Selection.Range
my company. What they want is to be able to push a button and a section
break will be inserted at the top of the document and a form will be inserted
above the break. I have created the code to do it. I saved the form
information under an AutoText Entry inside the template file (Form.dot). I
copied the form.dot to the startup folder where the other template files are
located. I can see the autotext entry in Tools/Autocorrect/Autotext when I
launch word. The Autotext entry (the actual form) can be inserted manually,
but when I try to insert it using VBA code it can't seem to find the Autotext
entry. I think I need to make a more detailed reference to it.
With the form.dot file located in the startup folder, I launch a blank word
file and when I start the macro it says:
Runtime error: 5941
The requested member of the collection does not exist
I can see the Autotext entry when I click on Tools/Autocorrect/Autotext, but
apparently the code is not calling it out. Here is the code I am using to
retrieve the autotext entry from the form.dot file located in the startup
folder and insert it into the current cursor position:
Application.DisplayAutoCompleteTips = True
With AutoCorrect
.CorrectInitialCaps = True
.CorrectSentenceCaps = True
.CorrectDays = True
.CorrectCapsLock = True
.ReplaceText = True
.ReplaceTextFromSpellingChecker = True
.CorrectKeyboardSetting = False
End With
ActiveDocument.AttachedTemplate.AutoTextEntries("Form").Insert Where _
:=Selection.Range