TrackEvent Simple Sample.xlsm

/TrackEvent Simple Sample.xlsm

TrackEvent Simple Sample.xlsm


Version 1
Download 1295
Total Views 1487
Stock
File Size 1.23 MB
File Type zip
Create Date 07/07/2017
Last Updated 09/08/2017
Please login to download

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. 1. Install the "VBA Telemetry Client" (VBATelemetrySetup.msi) it is in the zip file you have downloaded
  2. Create a FREE Azure account (if you already don't have one)
  3. In your Microsoft Azure portal create a new Application Insights resource.
  4. 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".

TrackEvent "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".

TrackEvent "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:

Flush

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.

 

 

 

2017-09-08T09:09:17+00:00 0 Comments

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.