vb.net和word 2010自动化 [英] vb.net and word 2010 automation

查看:80
本文介绍了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

推荐答案

我在另一个网站上得到了用户的帮助,答案非常简单。



需要添加:



I was helped by a user on another site, the answer was pretty simple.

Needed to add:

ApplicationInstance.Options.DefaultHighlightColorIndex = WdColorIndex.wdTurquoise



并改变这个:


And change this:

.Highlight = True


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆