views:

10903

answers:

4

What VBA code is required to peform an HTTP POST from an Excel spreadsheet?

Accepted Answer Note: For greater control over the HTTP request you can use "WinHttp.WinHttpRequest.5.1" in place of "MSXML2.ServerXMLHTTP"

A: 

I believe the ServerXMLHTTP object can used to do it.

Let me see if I can find a code sample.

Bill the Lizard nailed it :)

Mark Biek
A: 

I did this before using the MSXML library and then using the XMLHttpRequest object. See http://scriptorium.serve-it.nl/view.php?sid=40

Sijin
+14  A: 
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
   URL = "http://www.somedomain.com"
   objHTTP.Open "POST", URL, False
   objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
   objHTTP.send ("")
Bill the Lizard
For greater control over the HTTP request you can use "WinHttp.WinHttpRequest.5.1" instead of "MSXML2.ServerXMLHTTP"
Matthew Murdoch
A: 

I hope it's ok to ask a closely related question here, since I couldn't find anything in the site FAQs suggesting otherwise.

Can this be adapted so that the POST request is made and the resulting response is shown in the user's default web browser rather than returned behind the scenes to Excel (or in my case Access)? I want the user to fill out a form in Access and click a submit button, then arrive at the resulting webpage just as if the form had been a webpage in the first place.

So, technically speaking, I want VBA to create a POST request but have it actually executed by the user's web browser. This question is the closest I've come googling since all the search terms involved have such broad meanings. Is this even close?

Josh
@Josh - post this as a proper question and you'll get a better response (you can always embed a link to this question if you want).
Matthew Murdoch