Word/Excel HTTP POST

A little essoteric, but I recently needed to post some merge fields on a Word application form to a server to save on rekeying when the application form is completed.

Thankfully, VBA in Word can utilise any of the built-in Windows libraries and therefore the above can be easily accomplished using the MSXML2 library.

Some sample code for posting data to a HTTP server in VBA:

Private Sub PostData()  
  
  Set http = CreateObject("MSXML2.ServerXMLHTTP")  
  http.Open "POST", "http://mycompany.com/url/path", False  
  http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"  
  http.Send "field1=a&field2=b"  
  
  MsgBox http.responseText  
  
End Sub

WR
Wayne Robinson
Search the journal
46 entries · full-text · keyboard-first