View Single Post
  #4   Report Post  
Old November 8th 16, 05:01 AM posted to microsoft.public.excel.programming
Robert Baer Robert Baer is offline
external usenet poster
First recorded activity by ExcelBanter: Dec 2007
Posts: 70
Default File cannot be accessed

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?

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.