Monday 15 March 2010

Connect to web service in MS Access with VBA -


Is it possible to connect to a web service via VBA (for example, send an HTTP request) Microsoft Access? For example, if a user clicks on a button on a button, an HTTP request is sent to a web service that responds with OK .

Has anyone done this before?

Note: VBA, not VB.NET.

This code I have used quite successfully with Access 2003 It is from the interwab, copied and re-copied age first. It creates one, sends an HTTP GET request, and returns the result as a string. XMLHTTP = CreateObject ("MSXML2.XMLHTTP") XMLHTTP as a public function http_Resp (ByVal sReq as String) as a string dim byteData () object set as a byte dim XMLHTTP. Open "GET", sReq, False XMLHTTP.send byteData = XMLHTTP.responseBody Set XMLHTTP = None http_Resp = StrConv (byte data, vbUnicode) termination function

sReq URL; Function Responds You may need to ensure that ActiveX Data Objects are enabled under your reference (in the VBA editor, go to Tools> References).

No comments:

Post a Comment