Article ID: 183304
Article Last Modified on 6/17/2005
Sub AutoTextExists()
Dim atEntry As AutoTextEntry
' Look in normal template for
' specified autotext entry.
For Each atEntry In NormalTemplate.AutoTextEntries
If atEntry.Name = "Attention:" Then
MsgBox "Entry Exists!"
End If
Next atEntry
End Sub
Sub InsertAutoTextIfExist()
'This routine will insert the autotext entry if it exists.
Dim atEntry As AutoTextEntry
For Each atEntry In NormalTemplate.AutoTextEntries
If atEntry.Name = "Attention:" Then
atEntry.Insert Where:=Selection.Range
End If
Next atEntry
End Sub
Sub InsertAttachedTemplateAutoText()
' This routine will insert the autotext entry contained
' the active document's attached template if the specified
' autotext entry exists.
Dim atEntry As AutoTextEntry
For Each atEntry In ActiveDocument.AttachedTemplate.AutoTextEntries
If atEntry.Name = "Attention:" Then
atEntry.Insert Where:=Selection.Range
End If
Next atEntry
End Sub
For additional information, please see the following article in the
Microsoft Knowledge Base:
181058 OFF98: How to Run Sample Code from Knowledge Base Articles
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: wordcon vb vba vbe
Keywords: kbhowto kbmacroexample kbdtacode KB183304