0
votes

I am developing a word addin in c#. I have used the Find method to highlight the found search terms. (For background, see Find and Highlight issue in word addin).

I use the Find.Execute() method, but I want to use it more than once. But the highlighted words from the previous search are still highlighted.

How can I clear the old highlighted ranges before running method?

 word.Find find = rng.Find;
        find.Wrap = word.WdFindWrap.wdFindContinue;
        //find.Execute(findtext);
        find.Replacement.Highlight = 1;
        Globals.ThisAddin.Application.Options.DefaultHighlightColorIndex = Word.WdColorIndex.wdRed;
        find.Execute(FindText:wd,Replace: Word.WdReplace.wdReplaceAll,MatchWholeWord: true,MatchCase: true);
1
It's not clear what you are asking.Chris

1 Answers

0
votes

To remove highlighting from the body of the document:

Word.Document doc = Globals.ThisAddin.Application.ActiveDocument.InnerObject;
doc.Content.HighlightColorIndex = Word.WdColorIndex.wdNoHighlight;
//Now perform the Find