【问题标题】:How to clear the highlighting in VSTO如何清除 VSTO 中的突出显示
【发布时间】:2018-05-14 11:46:29
【问题描述】:

我正在c# 中开发word addin。我使用了Find 方法来突出显示找到的搜索词。 (背景见Find and Highlight issue in word addin)。

我使用Find.Execute() 方法,但我想多次使用它。但是之前搜索中突出显示的单词仍然突出显示。

如何在运行方法之前清除旧的突出显示范围?

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

【问题讨论】:

  • 不清楚你在问什么。

标签: c# ms-word vsto word-addins word-automation


【解决方案1】:

要从文档正文中删除突出显示:

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

【讨论】:

  • 如何使用find.Execute(...)方法从活动文档中删除下划线?下划线在哪里都需要去掉?
  • 这里我没有在 FindText 参数中作为参数传递的单词列表
  • @spidie_sridhar 我建议你问一个新问题。如果您认为它提供了重要的背景,您可以包含此讨论的链接。
猜你喜欢
  • 1970-01-01
  • 2016-03-12
  • 2011-09-01
  • 1970-01-01
  • 2010-10-14
  • 2014-07-31
  • 1970-01-01
  • 1970-01-01
  • 2017-07-17
相关资源
最近更新 更多