Hi folks,
Good Monday.
I have been pondering this dilemma over the weekend and need some advice.
Lets say I have multiple different wild card searches I need to run.
Can I do that from one script?
I hate to have to have 10 different wild card scripts.
So for example
Each wild card search targets a different text and applies some color to it
Sub MultipleWildCardsSearch()
Dim oRng As Word.Range
Dim lngIndex As Long
Dim oArraySearch() As String
Dim varLongColors
'Wild Cards Search -Can I store in an array or Select Case Statement?
oArraySearch = Split("ZX[0-9]", "\#b[0-9]", ",")
varLongColors = Array(RGB(0, 156, 250), RGB(256, 0, 0))
For lngIndex = 0 To UBound(oArraySearch)
Set oRng = ActiveDocument.Range
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = oArraySearch(lngIndex)
'.Format = True
.MatchWholeWord = True
'Find the wild card text
.Replacement.Text = oArraySearch(lngIndex)
.Replacement.Font.Color = varLongColors(lngIndex)
.Execute Replace:=wdReplaceAll
End With
Next
lbl_Exit:
Exit Sub
End Sub
What would be the best way for me to set up something like this. I wasn't sure if this was a loop within a loop or something
Many thanks for your time