![]() |
|
#1
|
|||
|
|||
|
Hi Community, This is a macro for removing specific highlight in Word Documents. When you place the cursor at the highlighted text (e.g., it highlighted wdYellow), then ran the macro, it can remove all wdYellow highlights in that word document. However, I found a bug in the "Removeonehighlight" macro. When there are words highlighted with two colors and connected each other like 123456, the macro cannot remove the highlight color, neither red or yellow one. (see the attached word file) The code are as follows: Code:
Sub Removeonehighlight()
Dim HLColor As WdColorIndex
Dim rg As Range
HLColor = Selection.Range.HighlightColorIndex
If HLColor <> wdNoHighlight Then
Set rg = ActiveDocument.Range
With rg.Find
.Highlight = HLColor
.Wrap = wdFindStop
While .Execute
If rg.HighlightColorIndex = HLColor Then
rg.HighlightColorIndex = wdNoHighlight
End If
rg.Collapse wdCollapseEnd
Wend
End With
Else
MsgBox "Please place you cursor on the highlight color you want to remove."
End If
End Sub
Your help would be greatly appreciated! |
| Tags |
| highlight, macro, word vba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
VBA Highlight numbers only after or before specific words help
|
Shelley Lou | Word VBA | 12 | 08-09-2022 03:02 AM |
Remove highlight with specific color
|
rekent | Word VBA | 2 | 08-01-2020 10:59 AM |
| How to highlight lines containing specific words | SixStringSW | Word VBA | 4 | 06-03-2018 03:57 PM |
| VBA to highlight specific values in the spreadsheet | daiwuliz | Excel | 6 | 05-23-2018 10:30 AM |
| Highlight the current cell without using code | parshla | Excel | 0 | 09-08-2016 08:10 PM |