Class Dictionary (Word VBA)

The class Dictionary 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.

To use a Dictionary class variable it first needs to be instantiated, for example

Dim dict as Dictionary
Set dict = CustomDictionaries(Index:=1)

The following procedures can be used to set variables of type Dictionary: Dictionaries.ActiveCustomDictionary, Dictionaries.Add, Dictionaries.Item, HangulHanjaConversionDictionaries.ActiveCustomDictionary, HangulHanjaConversionDictionaries.Add, HangulHanjaConversionDictionaries.Item, Language.ActiveGrammarDictionary, Language.ActiveHyphenationDictionary, Language.ActiveSpellingDictionary and Language.ActiveThesaurusDictionary.

For Each

Here is an example of processing the Dictionary items in a collection.

Dim dictCustomDictionary As Dictionary
For Each dictCustomDictionary In CustomDictionaries
	
Next dictCustomDictionary

Delete

Deletes the specified dictionary.

CustomDictionaries(1).Delete

LanguageID

Returns or sets a WdLanguageID constant that represents the language for the specified object. Here you can find possible values for WdLanguageID.

For a custom dictionary, you must first set the LanguageSpecific property to True before specifying the LanguageID property. Custom dictionaries that are language-specific check only text that is formatted for that language. Some WdLanguageID constants may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.

CustomDictionaries(1).LanguageID = wdAfrikaans

LanguageSpecific

True if the custom dictionary is to be used only with text formatted for a specific language.

Dim dicLoop As Dictionary 
 
For each dicLoop in CustomDictionaries 
 If dicLoop.LanguageSpecific = True Then dicLoop.Delete 
Next dicLoop

Name

Returns the name of the specified object.

Dim strName As String
strName = CustomDictionaries(1).Name

Path

Returns the path to the specified dictionary.

The path doesn't include a trailing character — for example, "C:\MSOffice" or "https://MyServer". Use the PathSeparator property to add the character that separates folders and drive letters. Use the Name property to return the file name without the path and use the FullName property to return the file name and the path together.

Dim strPath As String
strPath = CustomDictionaries(1).Path

ReadOnly

True if the specified dictionary cannot be changed.

The active grammar, hyphenation, spelling, and thesaurus dictionaries are read-only. Custom dictionaries are read/write.

Dim booReadOnly As Boolean
booReadOnly = CustomDictionaries(1).ReadOnly

Type

Returns the dictionary type. Here you can find possible values for WdDictionaryType.

Dim wdtType As WdDictionaryType
wdtType = CustomDictionaries(1).Type