Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2008

Tip: Looking for answers? Try searching our database.

If not found ignore

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steved - 17 Jan 2008 18:24 GMT
Hello from Steved

Please how can I tell the below code that if "L [0-9 ]" is not found ignore
and goto "R [0-9 ]"

Thankyou.

   Selection.Find.ClearFormatting
   With Selection.Find
       .Text = "L [0-9 ]"
       .Replacement.Text = ""
       .Forward = True
       .Wrap = wdFindContinue
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchAllWordForms = False
       .MatchSoundsLike = False
       .MatchWildcards = True
   End With
   Selection.Find.Execute
   Selection.MoveLeft Unit:=wdCharacter, Count:=3, Extend:=wdExtend
   Selection.Delete Unit:=wdCharacter, Count:=2
   Selection.EndKey Unit:=wdLine
   Selection.TypeText Text:=", "
   Selection.Delete Unit:=wdCharacter, Count:=1
   Selection.HomeKey Unit:=wdLine
   Selection.Find.ClearFormatting
   With Selection.Find
       .Text = "R [0-9 ]"
       .Replacement.Text = ""
       .Forward = True
       .Wrap = wdFindContinue
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchAllWordForms = False
       .MatchSoundsLike = False
       .MatchWildcards = True
   End With
   Selection.Find.Execute
   Selection.MoveLeft Unit:=wdCharacter, Count:=3, Extend:=wdExtend
   Selection.Delete Unit:=wdCharacter, Count:=2
   Selection.EndKey Unit:=wdLine
   Selection.TypeText Text:=", "
   Selection.Delete Unit:=wdCharacter, Count:=1
   Selection.HomeKey Unit:=wdLine
Tony Jollans - 17 Jan 2008 18:53 GMT
If Selection.Find.Execute = true Then
   ' Found so do whatever
Else
   ' Not found so don't do it
End If
' Get on with your life

The code you have looks like it has been recorded and it would probably be
as well to rework it so it wasn't emulating cursor movementand working with
Lines which are fickle things in Word - your Delete, for example, may or may
not make enough room on the line for the first word on the next line to flow
up.

Signature

Enjoy,
Tony

> Hello from Steved
>
[quoted text clipped - 44 lines]
>    Selection.Delete Unit:=wdCharacter, Count:=1
>    Selection.HomeKey Unit:=wdLine
Steved - 17 Jan 2008 19:02 GMT
Thankyou

> If Selection.Find.Execute = true Then
>     ' Found so do whatever
[quoted text clipped - 57 lines]
> >    Selection.Delete Unit:=wdCharacter, Count:=1
> >    Selection.HomeKey Unit:=wdLine
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.