M
MsMinxy
Hi,
I am currently using the following code to search for and highlight any of a
list of words in a Word document:
Sub ReplaceList()
Dim vFindText As Variant
Dim sReplText As String
Dim sHighlight As String
Dim i As Long
sHighlight = Options.DefaultHighlightColorIndex
Options.DefaultHighlightColorIndex = wdBrightGreen
vFindText = Array("Word1, "Word2", "Word3", "Word4", "Word5")
sReplText = ""
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = sReplText
.Replacement.Highlight = True
.Execute replace:=wdReplaceAll
Next i
End With
Options.DefaultHighlightColorIndex = sHighlight
End Sub
It words fine up to about 50 or so words, but I now have a list of several
hundred words and the array function will only allow you to type so many
characters within it before it breaks the line off and doesn't goes red. Is
there another way I can do this - i.e. have several consecutive arrays - or
specify the array in some other way which will allow an unlimited number of
characters and hence entries?
Any help, insight or suggestions would be greatfully appreciated!
X
MsMinxy
I am currently using the following code to search for and highlight any of a
list of words in a Word document:
Sub ReplaceList()
Dim vFindText As Variant
Dim sReplText As String
Dim sHighlight As String
Dim i As Long
sHighlight = Options.DefaultHighlightColorIndex
Options.DefaultHighlightColorIndex = wdBrightGreen
vFindText = Array("Word1, "Word2", "Word3", "Word4", "Word5")
sReplText = ""
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = sReplText
.Replacement.Highlight = True
.Execute replace:=wdReplaceAll
Next i
End With
Options.DefaultHighlightColorIndex = sHighlight
End Sub
It words fine up to about 50 or so words, but I now have a list of several
hundred words and the array function will only allow you to type so many
characters within it before it breaks the line off and doesn't goes red. Is
there another way I can do this - i.e. have several consecutive arrays - or
specify the array in some other way which will allow an unlimited number of
characters and hence entries?
Any help, insight or suggestions would be greatfully appreciated!
X
MsMinxy