Partager via


Dictionary Object (Word)

Represents a dictionary. Dictionary objects that represent custom dictionaries are members of the Dictionaries collection. Other dictionary objects are returned by properties of the Languages collection; these include the ActiveSpellingDictionary, ActiveGrammarDictionary, ActiveThesaurusDictionary, and ActiveHyphenationDictionary properties.

Remarks

Use CustomDictionaries(Index), where Index is an index number or the string name for the dictionary, to return a single Dictionary object that represents a custom dictionary. The following example returns the first dictionary in the collection.

CustomDictionaries(1)

The following example returns the dictionary named "MyDictionary."

CustomDictionaries("MyDictionary")

Use the ActiveCustomDictionary property to set the custom spelling dictionary in the collection to which new words are added. If you try to set this property to a dictionary that's not a custom dictionary, an error occurs.

Use the Add method to add a new dictionary to the collection of active custom dictionaries. If there is no file with the name specified by FileName, Word creates it. The following example adds "MyCustom.dic" to the collection of custom dictionaries.

CustomDictionaries.Add FileName:="MyCustom.dic"

Remarks

Use the Name and Path properties to locate any of the dictionaries. The following example displays a message box that contains the full path for each dictionary.

For Each d in CustomDictionaries 
 Msgbox d.Path & Application.PathSeparator & d.Name 
Next d

Use the LanguageSpecific property to determine whether the specified custom dictionary can have a specific language assigned to it with the LanguageID property. If the dictionary is language specific, it will verify only text that's formatted for the specified language.

For each language for which proofing tools are installed, you can use the ActiveGrammarDictionary, ActiveHyphenationDictionary, ActiveSpellingDictionary, and ActiveThesaurusDictionary properties to return the corresponding Dictionary objects. The following example returns the full path for the active spelling dictionary used in the U.S. English version of Word.

Set myspell = Languages(wdEnglishUS).ActiveSpellingDictionary 
MsgBox mySpell.Path & Application.PathSeparator & mySpell.Name

The ReadOnly property returns True for .lex files (built-in proofing dictionaries) and False for .dic files (custom spelling dictionaries).

See Also

Concepts

Word Object Model Reference

Dictionary Object Members