Class AutoTextEntry (Word VBA)
The class AutoTextEntry represents a single AutoText entry. The AutoTextEntry object is a member of the AutoTextEntries collection. The AutoTextEntries collection contains all the AutoText entries in the specified template. The entries are listed on the AutoText tab in the AutoCorrect dialog box. To use a AutoTextEntry class variable it first needs to be instantiated, for example
Dim ate as AutoTextEntry
Set ate = Dim strName As String: strName =
Dim strStyleName As String: strStyleName =
Selection.CreateAutoTextEntry(Name:=strName, StyleName:=strStyleName)
Delete
Deletes the specified object.
Selection.CreateAutoTextEntry.Delete
Index
Returns a Long that represents the position of an item in a collection.
Dim lngIndex As Long
lngIndex = Selection.CreateAutoTextEntry.Index
Insert
Inserts the AutoText entry in place of the specified range. Returns a Range object that represents the AutoText entry.
If you don't want to replace the range, use the Collapse method before using this method.
Sub InsertAutoTextEntry()
ActiveDocument.Content.Select
Selection.Collapse Direction:=wdCollapseEnd
ActiveDocument.AttachedTemplate.AutoTextEntries("one").Insert _
Where:=Selection.Range, RichText:=True
End Sub
Arguments
The following argument is required
Where (Range) - The location for the AutoText entry.
Optional arguments
The following argument is optional
RichText (String) - True to insert the AutoText entry with its original formatting.
Name
Returns or sets the name of the specified object.Read/write String.
Selection.CreateAutoTextEntry.Name =
StyleName
Returns the name of the style applied to the specified AutoText entry.
Set myentry = NormalTemplate.AutoTextEntries.Add(Name:="rsvp", _
Range:=Selection.Range)
MsgBox myentry.StyleName
Value
Returns or sets the value of the AutoText entry.
Setting the Value property only returns the first 255 characters of the object's value.
Selection.CreateAutoTextEntry.Value =