使用VSTO突出显示Word中所有出现的字符串 [英] Highlight all occurrences of a string in Word using VSTO
本文介绍了使用VSTO突出显示Word中所有出现的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想突出显示使用VSTO在Microsoft Word 2010中出现的给定字符串.
I would like to highlight all occurrences of a given string in Microsoft Word 2010 using VSTO.
到目前为止,我已经成功地使用Find
工具为比赛设置了前景色:
So far, I've managed to set the foreground color for the matches using the Find
facility:
Word.Find find = Application.ActiveDocument.Content.Find;
find.Replacement.Font.ColorIndexBi = Word.WdColorIndex.wdYellow;
find.Execute(FindText: "dog", MatchCase: false, Replace: Word.WdReplace.wdReplaceAll);
但是,我想为比赛设置亮点,如下面的屏幕截图所示:
However, I would like to set the highlight for the matches, such as in the screenshot below:
推荐答案
通过使用
Application.Options.DefaultHighlightColorIndex
到wdColorIndex成员之一(例如wdYellow)
to one of the wdColorIndex members (e.g. wdYellow)
在
find.Replacement.Highlight = True
这篇关于使用VSTO突出显示Word中所有出现的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文