LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default "On error" within While loop failing

OK, so I know using an "On error" within a While loop isn't terribly
kosher but I'm interfacing Excel with a realtime data system and the
existence/timing/availability of the key file is unpredictable. So I
have used the following VBA code:

' Work off copy to avoid file collisions
On Error GoTo againAgain:

bTryAgain = True
While bTryAgain = True
FileCopy sFullSrcFileName, sFullFileCopyName
bTryAgain = False
GoTo notAgain
againAgain:
Call addLogMsg("openOrders file conflict: " & Now())
notAgain:
Wend

The issue is that the 'On error' works fine the first time the file
isn't available. The log entry is made and the While loop restarts.
What's fascinating, and deeply annoying, is that the second time
through the loop execution halts at the "FileCopy". Simply halts with
the line highlighted. No warning pop-up, no loop, no thing else --
though an Error 70 has been triggered. The intent of the code is to
keep looping through the While loop until the FileCopy can succeed.
I'm not at all clear why the 'On error' logic stops after just one
error . Any ideas out there?

= M =
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using counter "i" in for loop gives error peter Excel Programming 4 June 7th 10 06:03 PM
"Coult not find specified object" and "Path-File access error" messages Robert Crandal Excel Programming 3 December 19th 09 09:12 PM
Question on determining "ROW" inside of a "For .. RANGE " loop David Schrader[_2_] Excel Programming 2 January 3rd 07 08:18 PM
"Select" and "Activate" failing? Ed Excel Programming 3 September 13th 06 06:29 PM
What is Error "Method "Paste" of object "_Worksheet" failed? vat Excel Programming 7 February 17th 06 08:05 PM


All times are GMT +1. The time now is 03:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"