Click here to Skip to main content
15,665,942 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.

For x As Integer = 0 To (dateConnected.Count() - 1)

    With oRng.Find
        .MatchCase = False
        .Text = dateConnected(x)

        With .Replacement
             .Text = dateConnected(x)
             .Highlight = Word.WdColor.wdColorTurquoise
        End With
    End With

1 solution

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
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