AutoTextEntries Property

Microsoft Word Visual Basic

Returns an AutoTextEntries collection that represents all the AutoText entries in the specified template. Read-only.

For information about returning a single member of a collection, see Returning an Object from a Collection.

Example

This example deletes the AutoText entry named "Hello" if the entry exists in the attached template.

Dim atEntry As AutoTextEntry

For Each atEntry In _

ActiveDocument.AttachedTemplate.AutoTextEntries
    If atEntry.Name = "asdf" Then atEntry.Delete
    Debug.Print atEntry.Name
Next atEntry
		

This example adds an AutoText entry named "Temp" to the Normal template. The contents of the AutoText entry (the first word in the document) are then displayed in a message box.

Dim atEntry As AutoTextEntry

Set atEntry = _
    NormalTemplate.AutoTextEntries.Add(Name:="Temp", _
    Range:=ActiveDocument.Words(1))

MsgBox atEntry.Value
		

This example stores the contents of the selection as an AutoText entry named "Address" in the attached template.

If Len(Selection.Text) > 1 Then
    ActiveDocument.AttachedTemplate.AutoTextEntries.Add _
        Range:=Selection.Range, Name:="Address"
End If