次の方法で共有


AutoTextEntry Object (Word)

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.

Remarks

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

The following example inserts the global AutoText entry named "TheWorld" at the insertion point.

Selection.Collapse Direction:=wdCollapseEnd 
NormalTemplate.AutoTextEntries("TheWorld").Insert _ 
 Where:=Selection.Range

Use the Add method to add an AutoTextEntry object 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

See Also

Concepts

Word Object Model Reference

AutoTextEntry Object Members