Identify a Different Template for AutoText Entry

R

Ridge Kennedy

Dear All,

I have a sub that works. It looks to the normal.dot. to Find an autotext
entry. I'd like to be able to tell it to look for a specific template
elsewhere -- not necessarily one of the default template directories. A
pointer in the direction of how to declare a different template as a
variable would be appreciated. And, does the templated have to be "open" to
be able to access an autotext entry??

Code for macro follows.

Thnaks

Ridge (in New Joisey)

Public Sub DocNameAndPath()
' a macro to use the standard Word autotext entry
' "Filename and Path" stored in the normal template
' to add the filename and path to the end of a document

Dim myRange As Range
Dim oDoc As Object
Set oDoc = ActiveDocument
Set myRange = oDoc.Range
myRange.Collapse (wdCollapseEnd)
myRange.InsertAfter (vbCrLf)
myRange.Font.Name = "arial"
myRange.Font.Size = 8
myRange.Font.Italic = False
myRange.Font.Bold = False
myRange.Paragraphs.Alignment = (wdAlignParagraphLeft)

NormalTemplate.AutoTextEntries("Filename and Path").Insert
Where:=myRange, RichText:=True
Set myRange = oDoc.Range
myRange.Collapse (wdCollapseStart)
myRange.Select

End Sub
 
O

Oliver Townshend

I have a sub that works. It looks to the normal.dot. to Find an autotext
entry. I'd like to be able to tell it to look for a specific template
elsewhere -- not necessarily one of the default template directories. A
pointer in the direction of how to declare a different template as a
variable would be appreciated. And, does the templated have to be "open"
to be able to access an autotext entry??

You could loop through the Templates collection and see if the Autotext
exists in it.

Alternatively, you can just do a type the text of the bookmark in, and the
do InsertAutoText.

Yes, it does need to be open.

Oliver Townshend
 
C

Charles Kenyon

It doesn't need to be open, it does need to be loaded. You load a template
and make its AutoText available to all document by putting it in the Word
Startup folder. This makes it an Add-In, and it will show up in the
templates collection. See http://addbalance.com/word/movetotemplate.htm for
step-by-step instructions on moving / sharing / copying / backing-up
customizations including AutoText, AutoCorrect, keyboard assignments,
toolbars, macros, etc.
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

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