vb.net突出显示文字

时间:2013-10-02 14:29:33

标签: vb.net ms-word automation

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

如果这是一个愚蠢的问题我道歉,我正在通过写这个来教自己VB。

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

1 个答案:

答案 0 :(得分:1)

Highlight属性接受true或false, 颜色索引由DefaultHighlightColorIndex属性确定,应用程序实例的哪个成员Option属性。

代码:

 ApplicationInstant.Options.DefaultHighlightColorIndex = Word.WdColorIndex.wdTurquoise
 .Highlight = True
相关问题