Class SpellingSuggestion (Word VBA)

The class SpellingSuggestion represents a single spelling suggestion for a misspelled word. The SpellingSuggestion object is a member of the SpellingSuggestions collection. The SpellingSuggestions collection includes all the suggestions for a specified word or for the first word in the specified range.

Set

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

Dim ssn as SpellingSuggestion
Set ssn = GetSpellingSuggestions(Index:=1)

The following procedures can be used to set variables of type SpellingSuggestion: SpellingSuggestions.Item, Application.GetSpellingSuggestions and Range.GetSpellingSuggestions

For Each

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

Dim strWord As String: strWord = 
Dim ssnGetSpellingSuggestion As SpellingSuggestion
For Each ssnGetSpellingSuggestion In GetSpellingSuggestions(Word:=strWord)
	
Next ssnGetSpellingSuggestion

Name

Returns the name of the specified object.

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

Parent

Returns an object that represents the parent object of the specified SpellingSuggestion object.

Dim objParent As Object
Set objParent = GetSpellingSuggestions(1).Parent

SpellingSuggestions.Count

Returns a Long that represents the number of spelling suggestions in the collection.

Dim lngCount As Long
lngCount = GetSpellingSuggestions.Count

SpellingSuggestions.Item

Returns an individual SpellingSuggestion object in a collection.

Syntax : expression.Item (Index)

Index: The individual object to be returned. Can be a Long indicating the ordinal position of the individual object.

Dim ssn As SpellingSuggestion
Set ssn = GetSpellingSuggestions(Index:=1)

SpellingSuggestions.Parent

Returns an object that represents the parent object of the specified SpellingSuggestions object.

Dim objParent As Object
Set objParent = GetSpellingSuggestions.Parent

SpellingSuggestions.SpellingErrorType

Returns the spelling error type.

Possible Values are wdSpellingCapitalization - Capitalization error, wdSpellingCorrect - Spelling is correct, wdSpellingNotInDictionary - The word is not in the specified dictionary.

Use the GetSpellingSuggestions method to return a collection of words suggested as spelling replacements. If a word is misspelled, the CheckSpelling method returns True.

Set suggs = ActiveDocument.Content.GetSpellingSuggestions 
If suggs.SpellingErrorType = wdSpellingNotInDictionary Then 
 StatusBar = "Unknown word" 
End If