AutoCorrectEntries Collection Object

Microsoft Word Visual Basic

AutoCorrectEntries Collection Object

         
Application AutoCorrect
AutoCorrectEntries (AutoCorrectEntry)

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 (Tools menu).

Using the AutoCorrectEntries Collection

Use the Entries property to return the AutoCorrectEntries collection. The following example displays the number of AutoCorrectEntry objects in the AutoCorrectEntries collection.

MsgBox AutoCorrect.Entries.Count

Use the Add or the AddRichText method to add an AutoCorrect entry to the list of available entries. The following example adds a plain-text AutoCorrect entry for the misspelling of the word "their."

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

The following example creates an AutoCorrect entry named "PMO" based on the text and formatting of the selection.

AutoCorrect.Entries.AddRichText Name:="PMO", Range:=Selection.Range

Use Entries(index), where index is the AutoCorrect entry name or index number, to return a single AutoCorrectEntry object. You must exactly match the spelling (but not necessarily the capitalization) of the name, as it's shown under Replace in the AutoCorrect dialog box. The following example sets the value of an existing AutoCorrect entry named "teh."

AutoCorrect.Entries("teh").Value = "the"

The following example displays the name and value of the first AutoCorrent entry.

MsgBox "Name = " & AutoCorrect.Entries(1).Name & vbCr & _
    "Value " & AutoCorrect.Entries(1).Value