Range.InsertAutoText method (Word)

Attempts to match the text in the specified range or the text surrounding the range with an existing AutoText entry name.

Syntax

expression. InsertAutoText

expression Required. A variable that represents a Range object.

Remarks

If Word finds a match, InsertAutoText inserts the AutoText entry to replace that text. If Word cannot find a match, an error occurs.

Use the Insert method with an AutoTextEntry object to insert a specific AutoText entry.

Example

This example inserts an AutoText entry that matches the text around a selection.

Documents.Add 
Selection.TypeText "Best w" 
Selection.Range.InsertAutoText

This example inserts an AutoText entry with a name that matches the first word in the active document.

Documents.Add 
Selection.TypeText "In " 
Set myRange = ActiveDocument.Words(1) 
myRange.InsertAutoText

See also

Range Object

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.