In today’s post, we are glad to share with you the effective way to remove a specific highlight color from your Word document.
In one of our previous articles, we have already talked about the ways to remove highlight colors. For detailed information, you can refer to this link: 5 Methods to Remove Highlighting or Shading in Your Word Document
Today, let look at another case that a document can contain multiple highlight colors to stand out different type of contents. In such a case, the usual ways fail to recognize one specific highlight color. As a matter of fact, the only quick and effective way is to run a Word macro.
Now take a look at bellowing approach.
Remove a Specific Highlight Color via VBA
- First and foremost, click “Developer” tab in the Ribbon.
- Then click “Visual Basic” to trigger the VBA editor in Word. And considering you may not have the “Developer” tab available yet, you can press “Alt+ F11” instead.
- Next click “Normal” project on the left column in the editor.
- Then click “Insert” tab on the menu bar.
- On the drop-down menu, choose “Module”.
- Now double click on new module to open the coding area.
- Paste the following macro on the module:
Sub RemoveSpecificHighlightColor() Dim objDoc As Document Dim objRange As Range Dim strHighlightColor As String Application.ScreenUpdating = False Set objDoc = ActiveDocument strHighlightColor = InputBox("Choose a Highlight colour to remove (enter the value):" & vbNewLine & _ vbTab & "Auto" & vbTab & vbTab & "0" & vbNewLine & _ vbTab & "Black" & vbTab & vbTab & "1" & vbNewLine & _ vbTab & "Blue" & vbTab & vbTab & "2" & vbNewLine & _ vbTab & "BrightGreen" & vbTab & "4" & vbNewLine & _ vbTab & "DarkBlue" & vbTab & vbTab & "9" & vbNewLine & _ vbTab & "DarkRed" & vbTab & vbTab & "13" & vbNewLine & _ vbTab & "DarkYellow" & vbTab & "14" & vbNewLine & _ vbTab & "Gray25" & vbTab & vbTab & "16" & vbNewLine & _ vbTab & "Gray50" & vbTab & vbTab & "15" & vbNewLine & _ vbTab & "Green" & vbTab & vbTab & "11" & vbNewLine & _ vbTab & "Pink" & vbTab & vbTab & "5" & vbNewLine & _ vbTab & "Red" & vbTab & vbTab & "6" & vbNewLine & _ vbTab & "Teal" & vbTab & vbTab & "10" & vbNewLine & _ vbTab & "Turquoise" & vbTab & "3" & vbNewLine & _ vbTab & "Violet" & vbTab & vbTab & "12" & vbNewLine & _ vbTab & "White" & vbTab & vbTab & "8" & vbNewLine & _ vbTab & "Yellow" & vbTab & vbTab & "7", "Highlight Color") With Selection .HomeKey Unit:=wdStory With Selection.Find .Highlight = True Do While .Execute If Selection.Range.HighlightColorIndex = strHighlightColor Then Set objRange = Selection.Range objRange.HighlightColorIndex = wdNoHighlight Selection.Collapse wdCollapseEnd End If Loop End With End With MsgBox ("The chosen highlight color has been removed in the document.") Application.ScreenUpdating = True Set objDoc = Nothing End Sub
- Then click “Run” button or hit “F5” to execute codes.
- Next, there is the “Highlight Color” box. There is a value for each color. Just enter the value related to the highlight color to be removed.
- Last but not the least, click “OK” to proceed.
- When it’s done, you will receive such a message box:
Here is the possible outcome:
Keep Your Data Safe
Data integrity can be easily compromised. It’s time to take preventive actions before all is too late. For example, the most recommended way is to back up files regularly. Always make sure you have the latest version to resort to while something unexpected happens. Otherwise, you will have to go through the Word recovery to get data back.
Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including fix xlsx and pdf repair software products. For more information visit www.datanumen.com
Datanumen, that was fantastic, so hard to find useable macros for us novices.
I merged this with another macro and create the extra row below with RGB
objRange.HighlightColorIndex = wdNoHighlight
objRange.Font.Shading.BackgroundPatternColor = RGB(255, 229, 153)
That worked like a charm to select all the Highlight of a Specific and convert to “Shading”, which has a superior range of colour pallet than “Highlight’s” simple 16 overly obtrusive colour pallet.
Now have to work out how to “Find and Replace” one RGB to another, couldn’t get this model to do that.
Happy online sailing to all, and beware of globalist agendas, alternate media are the only place for uncensored truth, start with searching your topics on duckduckgo, bitchute, rumble, telegram.. find experts that have been censored then let them tell you why, and why you need to know.
Gbu all 🙂
This is great! The only problem I had was that it didn’t work at first because I had leftover text in my Find dialog box. I’d suggest adding this line after ‘.Highlight = True’:
.Text = “”