Misspelling Vs. Duplicate

R

Ricardo Muiz

In VBA, how can you tell a misspelling from a duplicated word (a word marked
as a misspelling because it is repeated)? It appears programmatically Word
marks these two cases as the same even though the user interface clearly
knows the difference (since a different set of buttons become active).
 
J

Jay Freedman

Hi Ricardo,

The following demo shows how to distinguish the cases. The name of the
constant wdSpellingCorrect is unfortunate -- if the item was really
correct, it wouldn't be in the SpellingErrors collection.

Sub SpellDemo()
Dim msg As String
Dim rgError As Range
Dim suggs As SpellingSuggestions

For Each rgError In ActiveDocument.SpellingErrors
Set suggs = rgError.GetSpellingSuggestions

Select Case suggs.spellingErrorType
Case wdSpellingCorrect:
msg = "Repeated word"
Case wdSpellingNotInDictionary:
msg = "Not in dictionary"
Case wdSpellingCapitalization:
msg = "Incorrect capitalization"
End Select

rgError.Select
MsgBox msg
Next
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top