AutoTextEntries object (Word)

A collection of AutoCorrectEntry objects that represent the AutoText entries in a template. The AutoTextEntries collection includes all the entries listed on the AutoText tab in the AutoCorrect dialog box.

Remarks

Use the AutoTextEntries property to return the AutoTextEntries collection. The following example determines whether an AutoTextEntry object named "test" is in the AutoTextEntries collection.

For Each i In NormalTemplate.AutoTextEntries 
 If LCase(i.Name) = "test" Then MsgBox "AutoText entry exists" 
Next i

Use the Add method to add an AutoText entry to the AutoTextEntries collection. The following example adds an AutoText entry named "Blue" based on the text of the selection.

NormalTemplate.AutoTextEntries.Add Name:="Blue", _ 
 Range:=Selection.Range

Use AutoTextEntries (index), where index is the AutoText entry name or index number, to return a single AutoTextEntry object. You must exactly match the spelling (but not necessarily the capitalization) of the name, as it is shown on the AutoText tab in the AutoCorrect dialog box. The following example sets the value of an existing AutoText entry named "cName."

NormalTemplate.AutoTextEntries("cName").Value = _ 
 "The Johnson Company"

The following example displays the name and value of the first AutoText entry in the template attached to the active document.

Set myTemplate = ActiveDocument.AttachedTemplate 
MsgBox "Name = " & myTemplate.AutoTextEntries(1).Name & vbCr _ 
 & "Value " & myTemplate.AutoTextEntries(1).Value

Methods

Properties

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.