Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-21-2017, 11:29 PM
donlincolnmsof donlincolnmsof is offline Do Loop bug Windows 7 64bit Do Loop bug Office 2003
Advanced Beginner
Do Loop bug
 
Join Date: Oct 2011
Posts: 36
donlincolnmsof is on a distinguished road
Default Do Loop bug

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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Do Loop bug Macro Loop Help Twizzle008 Word VBA 15 09-18-2015 03:20 PM
Do Loop bug Loop - Row increment 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
Do Loop bug How to a For loop in VBA 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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:52 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft