Solved

Making a POST Request From VBA

Posted on 2001-08-09
3
1,178 Views
Last Modified: 2012-05-04
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
Comment
Question by:ubsjmg
  • 2
3 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6368191
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
 

Author Comment

by:ubsjmg
ID: 6373010
So I guess then I simply read the XML file with the ASP page.
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 100 total points
ID: 6373060
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question