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);