Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Identify a Different Template for AutoText Entry

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ridge Kennedy - 06 Mar 2006 19:07 GMT
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
Oliver Townshend - 06 Mar 2006 20:16 GMT
> 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
Charles Kenyon - 07 Mar 2006 01:25 GMT
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.
Signature


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

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
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.

> Dear All,
>
[quoted text clipped - 35 lines]
>
> End Sub
Ridge Kennedy - 08 Mar 2006 20:59 GMT
Thank you, Oliver and Charles.  R.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.