Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return to the top of a Do loop?

Status
Not open for further replies.

jbradleyharris

Programmer
Sep 29, 2001
15
US
I am trying to automate processing files from a list, created by another program, of pertinent files in a directory full of mainly irrellavant files. My program has a main loop that does the actual work. This is inside a loop that reads each file name from the list and passes it in to the main loop.

My problem is that the file names in the list are calculated and may not actually exist in the directory. When the selection loop tries to open one of these non-existant files it throws a File Not Found error, number 53. At this point I would like to jump back to the top of the selection loop to get the next file name but I don't know how. I tried to put a line in my error handler,

[blue]
Code:
If Err.Number = 53 Then Loop
[/blue]

but I get a Loop without Do error when I try that. I'm guessing that either I'm overlooking something obvious or I'm looking at this the wrong way. In any case, any suggestions would be greatly appreciated.

Thank in advance,
Brad Harris
 
Check that the file exists before you try to process it. Here's some pseudocode:
Code:
Do
  calculate file name
  if file exists then
    process file
  end if
Loop until all files processed
 
Will this work?

If Err.Number = 53 Then Err.Clear

An làmb a bheir, ‘s i a gheibh.
 
Thanks to both of you for your replies. Calculating all the file names and testing them, rejecting the names that don't exist is perfect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top