pradeepdeepu
01-13-2013, 11:05 PM
Hi,
I'm using the below code to highlight multi-word phrases in a word document.
This code is working fine for me, but i have more than 500 multi-words to update in array, which i feel is more time consuming and i am uncomfortable adding new multi-word to the array list - whenever i need to.
So is it possible to update all the multi-word phrases or words in an excel or a word document and refer that file to this code to find multi-word and highlight/format.
Dim oRng As Word.Range
Dim arrWords
Dim i As Long
arrWords = Array("I think that", "24-hr", "keep and immaculate")
For i = 0 To UBound(arrWords)
Set oRng = ActiveDocument.Range
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = arrWords(i)
.MatchWholeWord = True
.Replacement.Font.Underline = True
.Replacement.Font.TextColor = wdColorBlue
.Replacement.Font.Italic = True
.Execute Replace:=wdReplaceAll
End With
Next
Can anyone pls help me on this.
Thanks in Advance
I'm using the below code to highlight multi-word phrases in a word document.
This code is working fine for me, but i have more than 500 multi-words to update in array, which i feel is more time consuming and i am uncomfortable adding new multi-word to the array list - whenever i need to.
So is it possible to update all the multi-word phrases or words in an excel or a word document and refer that file to this code to find multi-word and highlight/format.
Dim oRng As Word.Range
Dim arrWords
Dim i As Long
arrWords = Array("I think that", "24-hr", "keep and immaculate")
For i = 0 To UBound(arrWords)
Set oRng = ActiveDocument.Range
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = arrWords(i)
.MatchWholeWord = True
.Replacement.Font.Underline = True
.Replacement.Font.TextColor = wdColorBlue
.Replacement.Font.Italic = True
.Execute Replace:=wdReplaceAll
End With
Next
Can anyone pls help me on this.
Thanks in Advance