MS Word 中的语法突出显示

发布于 2024-09-13 17:34:46 字数 156 浏览 2 评论 0原文

是否可以为 MS Word 创建一个插件或加载项,允许选择一段文本,然后对其应用自定义“突出显示”功能。

我希望这一切都在 MS Word 中,而不是从另一个应用程序中剪切和过去。

如果可能的话,关于我在哪里可以找到有关如何执行此操作的方向的任何建议(使用 C# )

Is it possible to create a plugin or addin for MS Word that allows a section of text to be selected and then a custom "Highlighting" function to be applied to it.

I want this to all be within MS Word not a cut and past from another application.

If possible, any suggestions on where I could find some direction on how to do this ( using C# )

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风吹短裙飘 2024-09-20 17:34:46

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

VBA - Visual Basic for Applications is your tool for this type of work in Office. It stays self-contained as well.

Shows manipulating text.

http://computerprogramming.suite101.com/article.cfm/introduction_to_vba_for_ms_word

VBA Tutorial:

http://jy.fridaynight.co.il/pages/dev/WordVBA.php

Bunch of examples.

http://www.thezcorp.com/VBACodeSamples.aspx

A Cornucopia:

http://www.java2s.com/Code/VBA-Excel-Access-Word/CatalogVBA-Excel-Access-Word.htm

Now that you know what to search for as well, hopefully you are on your way.

EDIT: Found this code example:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文