Bra Utbildning AB

 

<-- Back
VBA & Object models
Work with text
Bookmarks
Ranges
Fields
Form fields
Autotext
Doc var & Doc Prop
Built-in commands
Built-in dialogs
Automation
External databases

Work with Autotext


Insert autotext at insertion point/cursor's position
NormalTemplate.AutoTextEntries("Greetings").Insert _
   Where:=Selection.Range, _
   RichText:=True


ActiveDocument.AttachedTemplate.AutoTextEntries("Greetings").Insert _
   Where:=Selection.Range, _
   RichText:=True
 

Insert autotext from a loaded template. Path and file name has to be specified.
Templates("c:\data\MyAutotextLib.dot").AutoTextEntries("Greetings"). Insert _
   Where:=Selection.Range, _
   RichText:=True  


Insert autotext from any available/loaded template (Normal template, attached template and global templates) without specifying path and filename.   
Set oRng = Selection.Range
With oRng
   .Fields.Add _
      Range:=oRng, _
      Type:=wdFieldAutoText, _
      Text:="Greetings"
   .Fields.Unlink
End With