Microsoft Access and Slack Integration

It’s always fun and interesting to perform tasks using Microsoft Access that seem well outside the bounds of Access. A customer asked recently about the possibility of sending Slack messages to one of their Slack groups from an Access application based on certain events occurring in the Access application. After a couple of hours coding/testing, the feature was ready to go.

The first step is to create a Slack app and Webhook url in a Slack account.

Once that is in place, the lines of code below are all you need, +/- your unique requirements.

Set oXMLHTTP = CreateObject(“MSXML2.XMLHTTP.6.0”)
Set oXMLDoc = CreateObject(“MSXML2.DOMDocument”)

strEnvelope = “payload={“”SlackGroup””: “”API test””, “”text””: “”This is a Slack API msg test.””}”

Call oXMLHTTP.Open(“POST”, “”, False)
Call oXMLHTTP.setRequestHeader(“Content-Type”, “application/x-www-form-urlencoded”)
Call oXMLHTTP.send(strEnvelope)

Dim szResponse: szResponse = oXMLHTTP.responseText
Call oXMLDoc.loadXML(szResponse)