Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

on not found

4 views
Skip to first unread message

Kathy Webster

unread,
Nov 13, 2007, 3:32:37 PM11/13/07
to
How do I tell a word macro to search for a character string, and do x, y and
z. But if the character string is NOT found, go to the end of the sub?


Kathy Webster

unread,
Nov 13, 2007, 3:43:59 PM11/13/07
to
Found it on word.vba.beginners group...
If Selection.Find.Found = True Then
bla bla bla
End If

"Kathy Webster" <slic...@yahoo.com> wrote in message
news:473a0a03$0$28816$4c36...@roadrunner.com...

Doug Robbins - Word MVP

unread,
Nov 13, 2007, 4:29:37 PM11/13/07
to
You can also use the Instr() function. It returns 0 if the string being
searched for is not found. Therefore

If Instr(string1, string2) = 0 Then ' string1 does not contain string2
Exit Sub
Else
'Do x, y and z
End If

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Kathy Webster" <slic...@yahoo.com> wrote in message

news:473a0cc3$0$16446$4c36...@roadrunner.com...

0 new messages