How to Remove a Specific Highlight Color from Your Word Document

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.Remove a Specific Highlight Color from Your Word Document

Now take a look at bellowing approach.

Remove a Specific Highlight Color via VBA

  1. First and foremost, click “Developer” tab in the Ribbon.
  2. 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.
  3. Next click “Normal” project on the left column in the editor.
  4. Then click “Insert” tab on the menu bar.
  5. On the drop-down menu, choose “Module”.Click "Normal"->Click "Insert"->Click "Module"
  6. Now double click on new module to open the coding area.
  7. 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
  1. Then click “Run” button or hit “F5” to execute codes.Paste Macro->Click "Run"
  2. 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.
  3. Last but not the least, click “OK” to proceed.Enter Color Value->Click "OK"
  4. When it’s done, you will receive such a message box:Result Box

Here is the possible outcome:Result

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.

Author Introduction:

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

Leave a Reply

Your email address will not be published. Required fields are marked *