Logging from Microsoft Office and Visual Basic for Applications
While Python is my go-to language for anything substantial, I’ve found that Microsoft Excel and Visual Basic for Applications (VBA) scripting offer a fast path to creating automated and surprisingly sophisticated business dashboards and reports. The Loggly team will tell you that the stuff I do in Excel is simply scary…which I take as a compliment. I guess I do have an unnatural affection for Excel, but I digress…
HTTP POST and GET via VBA (Mac OS X and Windows)
Since we are a logging company, I naturally want to integrate logging and alerting into any automated process I create. So I’d like to share my tips on how to log from any Microsoft Office application – on Windows or Mac. Incidentally, the code is actually a cross-platform solution for any HTTP GET or POST from Microsoft Office.
Loggly supports logging to an HTTPS endpoint, and it’s this facility that you use to log directly from the VBA application. When invoking the function, you can optionally include one or more tags (separated by commas). I always use tags to identify my applications so that I can create source groups that segregate logs from different applications. This simplifies searching and alerting.
In the examples below, replace
TOKEN with your Customer Token. The
strEventmsg input parameter can be any string you like including JSON formatted. Choose the code for either Mac or Windows below.
The Loggly and SolarWinds trademarks, service marks, and logos are the exclusive property of SolarWinds Worldwide, LLC or its affiliates. All other trademarks are the property of their respective owners.