stevieb123
stevieb123

Reputation: 57

Highlighting words in Word 2013 but not case sensitive

I'm trying to highlight all words but at the moment it's doing it on a case sensitive basis which I'd like to avoid.

Sub Highlight_words()
    Dim range As range
    Dim i As Long
    Dim TargetList

    TargetList = Array("Array", "highlight", "With", "range", "matchcase")
        ' put list of terms to find here

    For i = 0 To UBound(TargetList)

        Set range = ActiveDocument.range

        With range.Find
            .Text = TargetList(i)
            .Format = True
            .MatchCase = True
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False

            Do While .Execute(Forward:=True) = True
                range.HighlightColorIndex = wdYellow
            Loop
        End With
    Next
End Sub

Upvotes: 0

Views: 178

Answers (1)

dennythecoder
dennythecoder

Reputation: 772

Change .MatchCase = true to the following:

.MatchCase = False

Cheers

Upvotes: 2

Related Questions