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.
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.
- 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.
- Then press “Ctrl+ H” to trigger the “Find and Replace” dialog box.
- Put cursor inside “Find what” text box.
- Click “More” to bring out more options and click “Format”.
- And choose “Highlight”.
- Next put cursor inside “Replace with” box and repeat step 4 and 5.
- Lastly, 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.
- First and foremost, press “Alt+ F11” to open VBA editor.
- Next click “Normal” project on the left column.
- Then click “Insert” tab on the menu bar.
- And choose “Module” on that drop-down menu.
- Open the new module by double click.
- 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
- Next click “Run” button or hit “F5”.
- 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.WdColorIndex
- For instance, if we want to replace the yellow color with bright green, we enter “7” in “Specify Highlight Color” box and click “OK”.
- 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.
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
Leave a Reply