Write Error to Log
This goes with the example Trap Those Errors. Told you that the error could be written to file but did not tell you how.Remember to do an “Exit Sub” inside your code before the Error Handler so that the Handler is not invoked each time your macro runs.
Exit Sub
ErrHandler:
Open "ErrorLog.log" For Append As #2 'Open file
Print #2, Application.Text(Now(), "mm/dd/yyyy HH:mm") _
; Error(Err); Err 'Write data
Close #2 'Close
Exit Sub 'Exit
End Sub
Open the file for Append, lay down the error date and message and close it again.
|