Error 67, “Too many files”, means the program asked for another open file when none could be granted: VBA's file numbers are a finite pool (1 to 511), and the operating system caps open handles per process as well. In living code this is nearly always a leak: files opened inside a loop, a search, or a per-record routine that are never closed, accumulating until the pool runs dry. The input data is rarely “too many”; the closes are too few.
For eachPath In paths
fn = FreeFile
Open eachPath For Input As #fn
' ... read ...
Close #fn ' inside the loop: outside, it leaks 510 times
Next
Reset closes all open files; if adding it “fixes” the error, it proves a leak exists upstream. Find the unpaired Open rather than sprinkling Reset.If opens and closes pair up correctly and error 67 still fires, look outside the file statements: thousands of files in a single directory can fail some operations on some systems, and the Dir() function itself, left mid-enumeration with a pattern, holds state. Test the same code against a smaller directory to separate pool exhaustion from directory scale.
How many files can VBA have open at once? File numbers run from 1 to 511, so at most 511 files through VBA file statements, and the operating system may impose its own per-process limit first. Either ceiling produces error 67.
Why does restarting fix error 67 temporarily? Because every open handle dies with the process. The leak restarts from zero, so the job runs until the leaked files accumulate to the limit again.