vb.net突出显示单词中的文本 [英] vb.net highlight text in word
问题描述
我在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?
如果这是一个愚蠢的问题,我深表歉意,我正在通过编写此书自学VB.
I apologize if this is a silly question, I am teaching myself VB by writing this.
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
推荐答案
Highlight 属性接受true或false, 颜色索引由 DefaultHighlightColorIndex 属性,应用程序实例的哪个成员Option属性.
the Highlight property accept true or false, the color index is determined by the DefaultHighlightColorIndex property, Which member Option property of application instance.
代码:
ApplicationInstant.Options.DefaultHighlightColorIndex = Word.WdColorIndex.wdTurquoise
.Highlight = True
这篇关于vb.net突出显示单词中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!