OK, just as I think I am getting good and projects start working like I think they should. I find the next wall.
I have the following code:
On Error GoTo ErrorHandler
Workbooks.Open Filename:=stDirectory & Format(stRptDate, "yyyymmdd") & ".csv"
When the file is not found goes to the ErrorHandler:
ErrorHandler:
' Check for error, then show message.
If Err.Number = 1004 And stRptDate = stDate Then
msg = "Error: The File can not be opened. " & _
vbNewLine & " - Click OK to Continue to the next File" & vbNewLine & _
" - Click CANCEL to Stop Processing"
msg = MsgBox(msg, vbOKCancel, "ERROR:")
If msg = vbOK Then
Err.Clear
GoTo SkipFile
End If
Else
msg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox msg, , "ERROR:"
End If
The idea is if the file is not found. You can continue the process (skipping the file). This works great the first time. But after that I just get the debugging popup box and is stops on the OPEN statement.
How do I make the ON ERROR command work for more than 1 error in the execution?