
#How to remove background highlighting in word code#
Apply the filtering code and deleting for the specific selection only, then check for a new page.Then go through each page and select the text. The code runs each page alone by making the code start from the first page and count the number of pages.

This happened with or without red highlighting color in the document. Once the MS Word got stuck, the cursor is changing rapidly, as if the screen has to be redrawn, and after a few seconds the program stops responding, and even if I wait for a while it will be stuck until I force to close the MS Word. 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. 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. The main issue is the While loop or any loop that I am using.


I want to delete the red highlighting color from the MS Word document.
