View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Robert Baer Robert Baer is offline
external usenet poster
 
Posts: 93
Default File cannot be accessed

wrote:
Hi
I have a macro that sequentially opens data files (csv data in .rnd files), copies data to the main workbook, then closes the file. This normally works well but when the number of files reaches some arbitrary number, around 200, I get the message: Filename "cannot be accessed.The file may be corrupted, located on a server that is not working or read-only."
If I process in blocks of less than 150 the same file opens without problems. It would be good though to keep all 250 files together. Any ideas of how to avoid the issue?
Thanks,
Rod

I think so.
The problem is made by having to many file handles, and the only way
that has a chance of preventing that is to close the files as soon as
possible: (open | read/copy | close) repeat for next file.