• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to handle un-expected error

ThrottleWorks

Excel Ninja
Hi,

I am writing below function to handle expected errors.

However I do not know how to handle un-expected errors.
Can anyone please help me in this.

Code:
ErrorLog "ERROR", "Worksheet Chandoo not present " & Now
Code:
Sub ErrorLog(Status, Msg As String)
    Set ts = fso.CreateTextFile(ThisWorkbook.Path & "/" & "ERROR.txt", True)
    ts.WriteLine Status
    ts.WriteLine ""
    ts.WriteLine Msg
    ts.Close
End Sub
 
Hi !

Why using FSO ? See in MSDN help to check if a file exists or
do not use FSO as VBA has yet all the necessary !

When a procedure handles any error, often errors are expected !
In the case of any unexpected error, the question is
what do you want to do ? …

See On Error in VBA inner help.
 
Back
Top