Class AutoTextEntries (Word VBA)

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. To use a AutoTextEntries class variable it first needs to be instantiated, for example

Add

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

Add (Name, Range)


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

Arguments

The following arguments are required:

Name (String) - The text that, when typed, initiates an AutoText entry.

Range (Range) - A range of text that will be inserted whenever Name is typed.

AppendToSpike

Deletes the specified range and adds the contents of the range to the Spike (a built-in AutoText entry). This method returns the Spike as an AutoTextEntry object.

The AppendToSpike method is only valid for the AutoTextEntries collection in the Normal template.

AppendToSpike (Range)

Range: The range that's deleted and appended to the Spike.


If Len(Selection.Range.Text) > 1 Then 
 NormalTemplate.AutoTextEntries.AppendToSpike _ 
 Range:=Selection.Range 
End If

Count

Returns the number of items in the AutoTextEntries collection.


Dim ates As AutoTextEntries: Set ates =  
Dim lngCount As Long
lngCount = ates.Count

Item

Returns an individual AutoTextEntry object in a collection.

Item (Index)

Index: The individual object to be returned. Can be a Long indicating the ordinal position or a String representing the name of the individual object.


Dim ates As AutoTextEntries: Set ates =  
Dim ate As AutoTextEntry
Set ate = ates(Index:=1)