Click here to Skip to main content
15,894,460 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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.


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
Posted

1 solution

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

Needed to add:

VB
ApplicationInstance.Options.DefaultHighlightColorIndex = WdColorIndex.wdTurquoise

And change this:
.Highlight = True
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900