View Single Post
 
Old 08-14-2015, 06:04 AM
rajani rajani is offline Windows XP Office 2007
Novice
 
Join Date: Jul 2015
Posts: 6
rajani is on a distinguished road
Question Create an input box for arrays

Hi All,

I need a help to complete my code and make it live.

Please help me to create an input box where the user has to insert the list of words with out going to the code. Here the word list is ("Friend", "MITS", "ICMR").

Note that the list of words varies from document to document.

Below is the code.

Sub FindHighlightWord()
Dim oRng As Word.Range
Dim arrWords
Dim i As Long

Options.DefaultHighlightColorIndex = wdGreen

arrWords = Array("Friend", "MITS", "ICMR")
For i = 0 To UBound(arrWords)
Set oRng = ActiveDocument.Range
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Highlight = True
.Text = arrWords(i)
.MatchWholeWord = True
.Execute Replace:=wdReplaceAll
End With
Next
End Sub

Many thanks for your help.

Regards,
Raj
Reply With Quote