Social Media
More About This Website

My name is Wayne Robinson and I'm a web applications developer from Queensland, Australia. In August 2005 I discovered Ruby on Rails and instantly fell in love. From that point forward, Ruby on Rails has been my language of choice for new projects however, I still use PHP to maintain some legacy applications.

Categories
Login
« Xero is greater than the rest | Main | QuickBooks and Terminal Services »
Tuesday
Jul282009

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

 

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (1)

Exactly what I needed for my latest Excel-project. I've implemented a Pac Man game in Excel/VBA (you play directly in the spreadsheet using specially formatted cells, so called "rough pic cells"). I will now complegte server-based high-score list before I release the game ;-)
July 30, 2010 | Unregistered CommenterHarry Harbinger

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
All HTML will be escaped. Hyperlinks will be created for URLs automatically.