Excel Macro : How to get notification when a VBA script stops execution -


I am running a macro on a remote PC which executes every 5 seconds throughout the day.

Now I want to be informed or notified via email if something goes wrong and macro prevents execution.

How can I do this?

MySub () error occurred on 'geton error' handler here '...' for a expected error if some WentWrong = true error then Rice number: = My arreber number, source: = "MySub", _ Description: = "This thing went wrong." Now Will go to the errorHandler end if 'More work was done here ... ExitProcedure: Error resume next Next' Cleanup code goes here ... Exit the sub error handler: 'If any error occurs (approximate or No), then the following will be executed. Call SendEmailNotification (_ Recipient: = "you@there.com", _ Subject: = "Something went wrong.", _ Message :: Error number and vbCrLf and error. Description and vbCrLf and Err.Source) Error management goes here ... Resume Exprro Processed and All

To send an e-mail, there are several solutions to search for CDO, searching on them You will find examples of writing your SendEmailNotification sub head above: None of these is absolutely clear

Comments