I'm trying to write a VBA macro that accepts all spelling suggestions. I've got this long automatic transcriptions full of things like repeated words. For some reason with MS Word Editor does not have an accept all function. This is what I'm working with:
Sub AcceptSpellingSuggestions()
Dim er As Range
For Each er In ActiveDocument.SpellingErrors
If er.GetSpellingSuggestions.Count > 0
Then er.Text = er.GetSpellingSuggestions.Item(1).Name
End If
Next
End Sub
This works with suggestions that have several options (it selects the 1st), but the problem is that errors like repeated words do not have suggestions. The options there are just "Ignore once" and "Remove repeated words". How can I make the macro select that second option?
CodePudding user response:
You can clean up repeated words with a wildcard Find/Replace, where:
Find = (<*>) \1
Replace = \1
No macro needed, but you can incorporate it into one. Do note that the cases of the repeated words must be the same. Note also that word repeats are sometimes intentional.