是否可以为 MS Word 创建一个插件或加载项,允许选择一段文本,然后对其应用自定义“突出显示”功能。
我希望这一切都在 MS Word 中,而不是来自另一个应用程序的剪切和过去。
如果可能的话,关于我在哪里可以找到如何做到这一点的方向的任何建议(使用 C#)
最佳答案
VBA - Visual Basic for Applications 是您在 Office 中进行此类工作的工具。它也保持独立。
显示操作文本。
http://computerprogramming.suite101.com/article.cfm/introduction_to_vba_for_ms_word
VBA 教程:
http://jy.fridaynight.co.il/pages/dev/WordVBA.php
一堆例子。
http://www.thezcorp.com/VBACodeSamples.aspx
聚宝盆:
http://www.java2s.com/Code/VBA-Excel-Access-Word/CatalogVBA-Excel-Access-Word.htm
既然您也知道要搜索什么,希望您已经上路了。
编辑:找到这个代码示例:
Sub ChangeColor
Options.DefaultHighlightColorIndex = wdBrightGreen
Selection.Find.ClearFormatting
Selection.Find.Highlight = True
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Highlight = True
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Font.Color = wdColorBrightGreen
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = wdColorRed
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
HTH
关于c# - MS Word 中的语法高亮显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3441923/