Class AutoCorrectEntries (Word VBA)

A collection of AutoCorrectEntry objects that represent all the AutoCorrect entries available to Word. The AutoCorrectEntries collection includes all the entries in the AutoCorrect dialog box. To use a AutoCorrectEntries class variable it first needs to be instantiated, for example


Dim aces as AutoCorrectEntries
Set aces = AutoCorrect.Entries

Add

Returns an AutoCorrectEntry object that represents a plain-text AutoCorrect entry added to the list of available AutoCorrect entries.

Use the AddRichText method to create a formatted AutoCorrect entry.

Add (Name, Value)


AutoCorrect.Entries.Add Name:="thier", Value:="their"

Arguments

The following arguments are required:

Name (String) - The text you want to have automatically replaced with the text specified by Value.

Value (String) - The text you want to have automatically inserted whenever the text specified by Name is typed.

AddRichText

Creates a formatted AutoCorrect entry, preserving all text attributes of the specified range. Returns an AutoCorrectEntry object.

The RichText property for entries added by using this method returns True. If AddRichText isn't used, inserted AutoCorrect entries conform to the current style.

AddRichText (Name, Range)


If Selection.Type = wdSelectionNormal Then 
 AutoCorrect.Entries.AddRichText "NewText", Selection.Range 
Else 
 MsgBox "You need to select some text." 
End If

Arguments

The following arguments are required:

Name (String) - The text to replace automatically with Range.

Range (Range) - The formatted text that Word will insert automatically whenever Name is typed.

Count

Returns the number of items in the AutoCorrectEntries collection.


Dim lngCount As Long
lngCount = AutoCorrect.Entries.Count

Item

Returns an individual AutoCorrectEntry 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 ace As AutoCorrectEntry
Set ace = AutoCorrect.Entries(Index:=1)