Hi,
I want to create a macro that will run at the end of a much longer macro that will search for specific key words in the newly edited document. I've done some searching here and online and found a code that I thought would work, which is supposed to identify specific words and highlight them. The code runs but nothing seems to happen upon completion. Here's that code:
Code:
Sub FindAndHighlight()
'
Application.ScreenUpdating = False
Dim StrFnd As String, Rng As Range, i As Long
StrFnd = "tasks,architecture,java"
For i = 0 To UBound(Split(StrFnd, ","))
Set Rng = ActiveDocument.Range
With Rng.Find
.ClearFormatting
.Text = Split(StrFnd, ",")(i)
.Replacement.ClearFormatting
.Replacement.Highlight = True
.Replacement.Text = "^&"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = True
.Execute Replace:=wdReplaceAll
End With
Next
Set Rng = Nothing
Application.ScreenUpdating = True
'
End Sub
I want the macro to search for 3 unrelated key words in the document and to alert the user that either there are no matches or that there are some. If this could happen via some sort of dialog box that would be great / highlighting the specific words as the code above describes.
Any suggestions as to what's wrong with the code above / what I can do? Thanks!