Inserting Autotext

K

kas

What is the code to insert an autotext entry at the beginning of a document?

Any help would be greatly appreciated.
 
J

Jay Freedman

What is the code to insert an autotext entry at the beginning of a document?

Any help would be greatly appreciated.

Assuming that the autotext entry is stored in the Normal.dot template,
that its name is TheEntry, and that you want it formatted as it was
stored and not as plain text, you can do this:

Dim MyRange As Range

Set MyRange = ActiveDocument.Range
MyRange.Collapse wdCollapseStart

NormalTemplate.AutoTextEntries("TheEntry").Insert _
Where:=MyRange, RichText:=True

A more complicated example is shown at
http://word.mvps.org/FAQs/MacrosVBA/NestedFieldsWithVBA.htm.
 
Top