Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1194
  • Last Modified:

Making a POST Request From VBA

I need to create an EXCEL application that POSTS data to an ASP page.  Can someone provide me with an example of how to do this in VBA?
0
ubsjmg
Asked:
ubsjmg
  • 2
1 Solution
 
Anthony PerkinsCommented:
This is one approach using XML:
Make a reference to XML (this code is using v2) and add this code:

Dim xmlReq As MSXML.XMLHTTPRequest
Dim xmlDoc As MSXML.DOMDocument
Dim HTTPRequest As String

Set xmlReq = New MSXML.XMLHTTPRequest
With xmlReq
   .open "POST", HTTPRequest, False
   .setRequestHeader "Content-Type", "text/xml"
   .send vbNullString
   Set xmlDoc = xmlReq.responseXML
End With
0
 
ubsjmgAuthor Commented:
So I guess then I simply read the XML file with the ASP page.
0
 
Anthony PerkinsCommented:
If you want to send a XML document to your ASP then change as follows:

Dim xmlHTTP As MSXML.XMLHTTPRequest
Dim xmlReq As MSXML.DOMDocument
Dim xmlResp As MSXML.DOMDocument
Dim HTTPRequest As String

Set xmlReq = New MSXML.DOMDocument
'build your xmlReq here

Set xmlHTTP = New MSXML.XMLHTTPRequest
With xmlHTTP
  .open "POST", HTTPRequest, False
  .setRequestHeader "Content-Type", "text/xml"
  .send xmlReq
  Set xmlResp = xmlHTTP.responseXML
  'Read the xmlResp here
End With

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now