Reputation: 3
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 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
Upvotes: 0
Views: 1872
Reputation: 6481
the Highlight property accept true or false, the color index is determined by the DefaultHighlightColorIndex property, Which member Option property of application instance.
code:
ApplicationInstant.Options.DefaultHighlightColorIndex = Word.WdColorIndex.wdTurquoise
.Highlight = True
Upvotes: 1