AutoTextEntries.Add Method

Word Developer Reference

Returns an AutoTextEntry object that represents an AutoText entry added to the list of available AutoText entries.

Syntax

expression.Add(Name, Range)

expression   Required. A variable that represents an AutoTextEntries collection.

Parameters

Name Required/Optional Data Type Description
Name Required String The text that, when typed, initiates an AutoText entry.
Range Required Range A range of text that will be inserted whenever Name is typed.

Example

This example adds an AutoText entry named Sample Text that contains the text in the selection. This example assumes you have text selected in the active document.

Visual Basic for Applications
  Sub AutoTxt()
    NormalTemplate.AutoTextEntries.Add Name:="Sample Text", _
        Range:=Selection.Range
End Sub

See Also