I'm working with the Selection.Find function in MS Word VBA. Is it possible to implement an If THEN ELSE statement that performs one thing if data is found, or another thing if no data is not found? My code is below.
Sub FindCustID
With Selection.Find
.Text = "Cust ID: ????"
'???? are 4 wildcards representing the customer ID
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
IF DATA IS FOUND.........
Do something
IF DATA IS NOT FOUND.....
Do something else
End Sub
Thanks.
--
Mike
Why make it simple and efficient when it can be complex and wonderful?
Sub FindCustID
With Selection.Find
.Text = "Cust ID: ????"
'???? are 4 wildcards representing the customer ID
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
IF DATA IS FOUND.........
Do something
IF DATA IS NOT FOUND.....
Do something else
End Sub
Thanks.
--
Mike
Why make it simple and efficient when it can be complex and wonderful?