
docx file type), once I run the code, it goes through the document pages and finds and deletes the red highlighting color, that once all are replaced, the MS Word stuck. What I noticed is, in some documents only (mixed of. Consequently, neither condition will be processed.
HOW TO REMOVE HIGHLIGHTING IN WORD DOCUMENT CODE
Additionally, I haven't included code to test whether a found range spans some text as well as part of a field or spans two or more highlight colours. End = Then Exit Doĭo note that there's a bug in Word's Find which means it won't find anything if the document consists of a single highlighted paragraph. 'The next line is needed if the highlighted content could include the final paragraph break Information(wdAtEndOfRowMarker) = True Then End If block is needed if the highlighted content could be in a table Find with a range the range is redefined each time a match is found, enabling you to change the properties of that range. In this instance you can avoid using Selection by using a Range object instead ( ActiveDocument.Content is a range). As Selection.Find selects every match it finds that is a lot of redrawing. When you select things in your code the screen has to be redrawn with each change of selection. The big problem with your code is that you are using the Selection object. The one shown in the code check for all highlighting colors and if the color is red, then remove it, otherwise check for another.

Execute Replace:=wdReplaceAll instead of the loop. Replacement.HighlightColorIndex = wdred and then. I'm not sure why it gets crashing, but I guess due to the loop that I am using. The following code is either working fine or make the MS Word stop responding. I made a module in MS Word documents that search/find any text highlighting with red color - a text marked with red from the tool shown in the image below. I want to delete the red highlighting color from the MS Word document.
