Article ID: 182304
Article Last Modified on 6/17/2005
Sub CheckForRepeatedWords()
Dim oSpErr As Object
Dim spSugg As SpellingSuggestions
Dim msg As String
Dim response As Integer
For Each oSpErr In ActiveDocument.SpellingErrors
Set spSugg = oSpErr.GetSpellingSuggestions
Select Case spSugg.SpellingErrorType
Case wdSpellingNotInDictionary
Case wdSpellingCapitalization
Case Else
'This case can be modified to perform a
'different function dependent upon the need.
oSpErr.Select
msg = "Delete this repeated word?"
response = MsgBox(msg, vbYesNoCancel, "Repeated Word")
If response = vbYes Then
Selection.Expand (wdWord)
Selection.Delete
End If
If response = vbCancel Then Exit Sub
End Select
Next
End Sub
181058 OFF98: How to Run Sample Code from Knowledge Base Articles
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: wordcon vb vba vbe
Keywords: kbbug kbmacroexample kbdtacode kbpending KB182304