TrackError Simple Sample.xlsm

In this simple Excel Workbook you can see how to use the TrackError function with VBA Telemetry Client to send tracking data about your errors from your Excel Workbook within VBA to Microsoft Azure - Application Insights.

What does this sample do:

Watch this short (50sec) video on how this sample works:

When we click on the Button the error Division by zero is triggered.
In Error_Handler we have placed a line of code that calls a function TrackError and passes the parameters about the error to this function.
This function then sends the data about the error to our Application Insights resource.
We can see our error in Azure Portal - our Application Insights resource in tab Failures.

In this sample we have inserted 1 line of VBA code into ThisWorkbook: (To open the VBA Editor goto Developer > Visual Basic OR press Alt + F11)

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'before we exit, we need to Flush the data so that VBA Telemetry Client & Application Insights Client knows that it needs to send the rest of the data to the Azure
Flush
End Sub