View Single Post
 
Old 08-14-2015, 06:27 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

How about
Code:
Sub FindHighlightWord()
Dim oRng As Word.Range
Dim vWords As Variant
Dim i As Long
Dim strWords As String
    strWords = InputBox(Prompt:="Enter the words to highlight separated by commas", _
                        Title:="Highlight words", _
                        Default:="Friend,MITS,ICMR")

    vWords = Split(strWords, ",")
    For i = 0 To UBound(vWords)
        Set oRng = ActiveDocument.Range
        With oRng.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            Do While .Execute(FindText:=Trim(vWords(i)), _
                              MatchWholeWord:=True) = True
                oRng.HighlightColorIndex = wdBrightGreen
                oRng.Collapse 0
            Loop
        End With
    Next
lbl_Exit:
    Set oRng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote