我想使用 VSTO 在 Microsoft Word 2010 中突出显示给定字符串的所有匹配项。
到目前为止,我已经成功地使用Find 工具为匹配项设置了前景色:
Word.Find find = Application.ActiveDocument.Content.Find;
find.Replacement.Font.ColorIndexBi = Word.WdColorIndex.wdYellow;
find.Execute(FindText: "dog", MatchCase: false, Replace: Word.WdReplace.wdReplaceAll);
但是,我想为比赛设置高亮显示,如下面的截图:
请您参考如下方法:
如果想要临时高亮,可以使用 HitHighlight 方法:
Word.Find find = Application.ActiveDocument.Content.Find;
find.HitHighlight(
FindText: "dog",
MatchCase: false,
HighlightColor: Word.WdColor.wdYellow);
