2 Useful Methods to Replace Highlight Color in Your Word Document

In this article, we are delighted to show you 2 useful methods to replace the highlight color in your Word document.

Sometimes you may highlight different contents with different colors. But unlike font color, you cannot utilize the “Find and Replace” to find texts in a specific highlight color and replace it with another one.

Therefore, we are going to need some workarounds. Following are 2 ways available for different cases.Replace Highlight Color in Your Word Document

Method 1: Replace All Highlight Colors with the Same One

The highlight color associated to “Find and Replace” dialog box is the current one selected in the Highlight icon.

  1. First of all, under “Home” tab and in “Font” group, click on the drop-down button on “Text Highlight Color” command. Pick a color to which you want change all highlight colors. For example, we choose “Bright Green” here.Click "Home"->Click Drop-down Button on "Text Highlight Color" Command->Choose a Color
  2. Then press “Ctrl+ H” to trigger the “Find and Replace” dialog box.
  3. Put cursor inside “Find what” text box.
  4. Click “More” to bring out more options and click “Format”.
  5. And choose “Highlight”.Click "Format"->Click "Highlight"
  6. Next put cursor inside “Replace with” box and repeat step 4 and 5.
  7. Lastly, click “Replace All”.Click "Replace All"

Now you have replaced all highlight colors with the bright green.

Method 2: Replace a Specific Highlight Color with Another

To accomplish this task, a macro is required.

  1. First and foremost, press “Alt+ F11” to open VBA editor.
  2. Next click “Normal” project on the left column.
  3. Then click “Insert” tab on the menu bar.
  4. And choose “Module” on that drop-down menu.Click "Normal"->Click "Insert"->Click "Module"
  5. Open the new module by double click.
  6. Now paste following codes:
Sub ReplaceOneHighlightColorToAnother()
  Dim strFindColor As String
  Dim strReplaceColor As String
  Dim objDoc As Document
  Dim objRange As Range
 
  Application.ScreenUpdating = False
 
  Set objDoc = ActiveDocument
 
  strFindColor = InputBox("Specify a color (enter the value):", "Specify Highlight Color")
  strReplaceColor = InputBox("Specify a new color (enter the value):", "New Highlight Color")
 
  With Selection
    .HomeKey Unit:=wdStory
    With Selection.Find
      .Highlight = True
 
      Do While .Execute
        If Selection.Range.HighlightColorIndex = strFindColor Then
          Set objRange = Selection.Range
          objRange.HighlightColorIndex = strReplaceColor
          Selection.Collapse wdCollapseEnd
        End If
      Loop
    End With
  End With
 
  Application.ScreenUpdating = True
End Sub
  1. Next click “Run” button or hit “F5”.Paste Codes->Click "Run"
  2. Then in the “Specify Highlight Color” box, enter a value represent the color to be replaced. To get the corresponding value of a specific color, you can visit this link: https://docs.microsoft.com/en-us/office/vba/api/Word.WdColorIndexColor Values
  3. For instance, if we want to replace the yellow color with bright green, we enter “7” in “Specify Highlight Color” box and click “OK”.Enter a Value->Click "OK"
  4. Then in “New Highlight Color” box, enter a value of the new color and click “OK”.

Here is the possible outcome of replacing yellow with bright green.Result of Changing Yellow Color to Bright Green

Avoid Data Loss Disaster

Word is such a great helper in our daily work. Therefore, it’s not hard to imagine the catastrophe it can bring when it collapses. To avoid losing critical data, you can get hold of a Word fix tool in advance. With such a utility at hand, you should not need to worry about the data loss.

Author Introduction:

Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupt xlsx and pdf repair software products. For more information visit www.datanumen.com

4 responses to “2 Useful Methods to Replace Highlight Color in Your Word Document”

  1. Office 365 kullanıyorum. Bunu vurgu renginin bulunduğu karakterleri silmek için nasıl bir kod düzenlemesi olması gerekir? Bitişik farklı renkteki vurgularda uygulayabilir miyiz?

  2. I think the macro only works if there is an unhighlighted gap between colours. If you have two different colours of highlight touching each other the macro finds one example of highlighting and determines that its “colour” is 999999 or something weird like that, the code for mixed. The only way round this is to then go through the mixed highlighting character by character to determine where the colour change happens, and then identify the range as two separate colour ranges, to which the macro can apply separately. It is possible but much clunkier and slower.

  3. I copied your VBA code and ran it. No error but it didn’t appear to do anything. I tried several variations of highlight colors such as pink (5), yellow (7), and bright green (4). Perhaps there was a VBA update with Office 365 version, which caused this change. The find and replace worked fine.

Leave a Reply

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