本文介绍了vb.net和word 2010自动化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS 2012 Express中使用VB.NET来自动化Word 2010.我正在尝试找到一个字符串,然后在Turquoise中突出显示它。我的代码可以找到并突出显示它,但它以默认的黄色进行。如何将其更改为所需的颜色?



我确定这是一个简单的修复,只是不确定我缺少什么。





I am using VB.NET in VS 2012 Express to automate Word 2010. I am trying to find a string and then highlight it in Turquoise. My code works to find and highlight it, but it does it in the default yellow color. How can I change that to the desired color?

I am sure this is a simple fix, just not sure what I am missing.


For x As Integer = 0 To (dateConnected.Count() - 1)

    With oRng.Find
        .MatchCase = False
        .ClearFormatting()
        .Text = dateConnected(x)

        With .Replacement
             .ClearFormatting()
             .Text = dateConnected(x)
             .Highlight = Word.WdColor.wdColorTurquoise
        End With
       .Execute(Replace:=Word.WdReplace.wdReplaceAll)
    End With
Next

推荐答案

ApplicationInstance.Options.DefaultHighlightColorIndex = WdColorIndex.wdTurquoise



并改变这个:


And change this:

.Highlight = True


这篇关于vb.net和word 2010自动化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 14:47