- Version 1
- Download 1336
- File Size 1.23 MB
- File Count 1
- Create Date 07/07/2017
- Last Updated 02/26/2019
TrackEvent Simple Sample.xlsm
This is a simple Excel Workbook that shows you how to use the TrackEvent function with VBA Telemetry Client to send tracking data from your Excel Workbook within VBA to Microsoft Azure - Application Insights.
Before you can use it:
- 1. Install the "VBA Telemetry Client" (VBATelemetrySetup.msi) it is in the zip file you have downloaded
- Create a FREE Azure account (if you already don't have one)
- In your Microsoft Azure portal create a new Application Insights resource.
- Copy from your newly created Application Insights resource the Instrumentation Key and paste it into module modVBATelemetryVariables.
Detailed steps how to do this can be found in our Documentation section on our webpage VBATelemetry.com
What is added in this Excel Workbook:
In VBA Editor:
In ThisWorkbook few lines of code are added:
We want to track when our users open our workbook, so we added in event Workbook_Open () a line of code that will send to Application Insights an event that we named "WorkbookOpen".
We also want to track when our users exit our workbook, so we added in event Workbook_BeforeClose() a line of code that will send to Application Insights an event that we named "WorkbookBeforeClose".
Because the VBA Telemetry Client and Application Insights Client are not sending data to Microsoft Azure immediately when it happens, but it stores this data in a buffer and from time to time it sends it in chunks. This is why we need to tell VBA Telemetry Client that we are done and that it can send the rest of the data to Azure. This is done with this line of code:
We need to put this in our VBA before we exit our application. This is why this line of code is in Workbook_BeforeClose event.