PDA

View Full Version : [SOLVED:] Highlight All Spelling and/or Grammatical Errors?



VB-AN-IZ
10-18-2016, 06:31 AM
Walking down a similar path to another thread which was recently solved:


http://www.vbaexpress.com/forum/showthread.php?57443-Highlight-All-Words-Containing-Capital-Letters

How could I highlight all words picked up in a spellcheck?

This is how to highlight all words containing a capital letter:


Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng.Find
Do While .Execute(FindText:="[A-Z]*>", MatchWildcards:=True)
oRng.HighlightColorIndex = wdYellow
oRng.Collapse 0
Loop
End With
lbl_Exit:
Exit Sub
End Sub

Thanks!

gmaxey
10-18-2016, 06:05 PM
Note you can't isolate just the squiggly underlined part of a grammatical error:



Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey
Dim oSE As Range, oGE As Range
For Each oSE In ActiveDocument.SpellingErrors
oSE.HighlightColorIndex = wdYellow
Next
For Each oGE In ActiveDocument.GrammaticalErrors
oGE.HighlightColorIndex = wdBrightGreen
Next
lbl_Exit:
Exit Sub
End Sub

VB-AN-IZ
10-19-2016, 02:45 AM
Brilliant. Thanks so much!