Error Handler Not Working in Access VBA
Posted on 2007-11-29
I'm importing a set of CSV files into Access.
My procedure loops through a list of filepaths kept in a table. Some days, some of the files will not exist so I want the code to proceed to the next in the list. I've used On Error Resume Next, On Error GoTo Move_To_Next_File etc - all the usual error handling techniques - but my code still breaks.
I'm using the Scripting FileSystemObject library in this procedure. Some of the source files have "." in the filename (which Access cannot import) so I use FSO's file.copy method to copy the file to a temporary folder under a different name, then import. However, when I encounter a file that does not exist it breaks here:
Set file = FSO.GetFile(filepath)
It will not Resume Next or GoTo the label I specify.