G
G Teachman
Hello,
I'm scanning a document for the existence of the character string "| Not
rated". Then copying the selected area of text into another document. I use
a Do While loop. If "| Not rated" is found then do stuff. What I can't get
it to do is if it doesn't find "| Not rated" skip the rest of the stuff and
continue in the loop.
Here is the code in question:
Do Until <stuff>
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=4, Extend:=wdExtend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "| Not rated"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveUp Unit:=wdLine, Count:=2, Extend:=wdExtend
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
<more stuff>
Loop
So if the Execute statement is TRUE then the right stuff continues. Not a
problem, this works. However, if the Execute statement is FALSE I want the
system to return to the beginning of the LOOP.
I can make it exit the loop by using 'Exit Do' command. However, this isn't
what I want it to do. I want it to go to the top of the DO WHILE command and
continue.
Any help would be very much appreciated.
Thanks,
I'm scanning a document for the existence of the character string "| Not
rated". Then copying the selected area of text into another document. I use
a Do While loop. If "| Not rated" is found then do stuff. What I can't get
it to do is if it doesn't find "| Not rated" skip the rest of the stuff and
continue in the loop.
Here is the code in question:
Do Until <stuff>
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=4, Extend:=wdExtend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "| Not rated"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveUp Unit:=wdLine, Count:=2, Extend:=wdExtend
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
<more stuff>
Loop
So if the Execute statement is TRUE then the right stuff continues. Not a
problem, this works. However, if the Execute statement is FALSE I want the
system to return to the beginning of the LOOP.
I can make it exit the loop by using 'Exit Do' command. However, this isn't
what I want it to do. I want it to go to the top of the DO WHILE command and
continue.
Any help would be very much appreciated.
Thanks,