Computer Forum Forum Index
Register  FAQ Profile Log in to check your private messages Log in Register 

on not found

 
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word programming
View previous topic :: View next topic  
Author Message
Kathy Webster
Guest





PostPosted: Tue Nov 13, 2007 8:32 pm    Post subject: on not found Reply with quote

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?
Back to top
Google
Sponsor





PostPosted: Tue Nov 13, 2007 8:32 pm    Post subject: Advertisement

Back to top
Kathy Webster
Guest





PostPosted: Tue Nov 13, 2007 8:43 pm    Post subject: Re: on not found Reply with quote

Found it on word.vba.beginners group...
If Selection.Find.Found = True Then
bla bla bla
End If

"Kathy Webster" <slickdock@yahoo.com> wrote in message
news:473a0a03$0$28816$4c368faf@roadrunner.com...
Quote:
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?
Back to top
Doug Robbins - Word MVP
Guest





PostPosted: Tue Nov 13, 2007 9:29 pm    Post subject: Re: on not found Reply with quote

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" <slickdock@yahoo.com> wrote in message
news:473a0cc3$0$16446$4c368faf@roadrunner.com...
Quote:
Found it on word.vba.beginners group...
If Selection.Find.Found = True Then
bla bla bla
End If

"Kathy Webster" <slickdock@yahoo.com> wrote in message
news:473a0a03$0$28816$4c368faf@roadrunner.com...
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?


Back to top
Display posts from previous:   
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Computer Forum