Highlight all occurrences of a string in Word using VSTO

老子叫甜甜 提交于 2019-12-04 19:40:09

Set the highlight colour by setting using

Application.Options.DefaultHighlightColorIndex 

to one of the wdColorIndex members (e.g. wdYellow)

Apply the Highlight colour in a Replace using

find.Replacement.Highlight = True

If one wants temporary highlighting, one may use the HitHighlight method instead:

Word.Find find = Application.ActiveDocument.Content.Find;
find.HitHighlight(
    FindText: "dog",
    MatchCase: false,
    HighlightColor: Word.WdColor.wdYellow);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!