Class Dictionaries (Word VBA)

A collection of Dictionary objects that includes the active custom spelling dictionaries. To use a Dictionaries class variable it first needs to be instantiated, for example


Dim dcts as Dictionaries
Set dcts = CustomDictionaries

ActiveCustomDictionary

Returns or sets a Dictionary object that represents the custom dictionary to which words will be added.


Set dicCustom = Application.CustomDictionaries.ActiveCustomDictionary 
MsgBox dicCustom.Path & Application.PathSeparator & dicCustom.Name

Add

Returns a Dictionary object that represents a new custom spelling or conversion dictionary added to the collection of active custom spelling or conversion dictionaries.

If a file with the name specified by the FileName parameter doesn't exist, Microsoft Word creates one. The Dictionaries collection includes only the active custom spelling dictionaries. Dictionary objects that are derived from the Languages collection don't have an Add method. These include the Dictionary objects returned by the ActiveSpellingDictionary, ActiveGrammarDictionary, ActiveThesaurusDictionary, and ActiveHyphenationDictionary properties. Use the HangulHanjaDictionaries property to return the collection of custom conversion dictionaries. The HangulHanjaConversionDictionaries collection includes only the active custom conversion dictionaries.

Add (FileName)

FileName: The string name of the dictionary file. If no path is specified in the string, the proofing tools path is used.


With CustomDictionaries 
 .ClearAll 
 .Add FileName:="c:\My Documents\MyCustom.dic" 
 .ActiveCustomDictionary = CustomDictionaries(1) 
End With

ClearAll

Unloads all of the custom or conversion dictionaries.


CustomDictionaries.ClearAll

Count

Returns a Long that represents the number of dictionaries in the collection.


Dim lngCount As Long
lngCount = CustomDictionaries.Count

Item

Returns an individual Dictionary 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 dict As Dictionary
Set dict = CustomDictionaries(Index:=1)

Maximum

Returns the maximum number of custom or conversion dictionaries allowed.


If CustomDictionaries.Count = CustomDictionaries.Maximum Then 
 MsgBox "Cannot add another dictionary file" 
Else 
 CustomDictionaries.Add "MyDictionary.dic" 
End If