MS Word中的语法高亮显示
问题描述:
是否可以为MS Word创建插件或插件,以便选择一段文本,然后对其应用自定义的“突出显示”功能。MS Word中的语法高亮显示
我希望这一切都在MS Word中,而不是从另一个应用程序中剪切和过去。
如果可能的话,在那里我能找到如何做到这一点(使用C#)某个方向有什么建议
答
VBA - Visual Basic应用程序是您给这个类型在办公室工作的工具。它保持独立。
显示操纵文本。
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
见上文新的代码。 – JustBoo 2010-08-09 16:55:38