![]() |
#1
|
|||
|
|||
![]()
Hello
I have the following do loop, it processes all the data, but its crashed ON SELECTION.CUT ALMOST AT THE END OF THE LOOP. A bit i understand there has to be some sort of check for terminate the do loop. Any help will be appreciated. Thanks. Do Selection.Find.ClearFormatting With Selection.Find .Text = "Add to watchlist" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Selection.Delete Unit:=wdCharacter, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=2 Selection.EndKey Unit:=wdLine, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.Cut Windows(1).Activate Selection.Paste Selection.TypeText Text:=vbTab Selection.TypeParagraph Windows(2).Activate Loop Until Selection.Find.Found = False Selection.HomeKey Unit:=wdStory Windows(1).Activate Selection.HomeKey Unit:=wdStory Windows(2).Activate Selection.HomeKey Unit:=wdStory Do Selection.Find.ClearFormatting With Selection.Find .Text = "TOTAL REVENUE" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Selection.HomeKey Unit:=wdLine Selection.EndKey Unit:=wdLine, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.Cut Windows(1).Activate Selection.EndKey Unit:=wdLine Selection.TypeText Text:=vbTab Selection.Paste Selection.TypeParagraph Selection.Delete Unit:=wdCharacter, Count:=1 Windows(2).Activate Loop Until Selection.Find.Found = False |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Twizzle008 | Word VBA | 15 | 09-18-2015 03:20 PM |
![]() |
jrt | Excel Programming | 1 | 04-16-2015 01:46 PM |
What's wrong with my loop? | Irrma | Word VBA | 2 | 06-17-2014 06:25 AM |
![]() |
Jennifer Murphy | Word VBA | 1 | 01-29-2013 03:30 AM |
How to use for loop in formula in VBA? | tinfanide | Excel Programming | 1 | 12-06-2011 08:33 AM |