In VBA after automated xml form post, how can I automate interaction with the response?

excel-yes

New Member
Joined
May 10, 2011
Messages
9
I am using xml in VBA. The code below adds an item to a shopping cart on a remote website (posts a form). Then the code displays the result in Internet Explorer.

You can see in the response there is a "get estimates" button. I need to automatically click that, enter location info, and get the response of shipping and tax charges (for the item currently in the cart) on my excel 2010 worksheet.

I want all the automated clicking and entering data to happen with the site (the site's server?) directly like when I added the item to the shopping cart, not through the browser if possible. It takes a long time for the page to load and I think if I go through a browser I could do that without xml anyway. But I'm really stuck so if I have to load a browser that's okay too.

Code:
Option Explicit

Sub testing()
    Dim objIE As Object
    Dim xmlhttp As Object
    Dim response As String
     Set objIE = CreateObject("InternetExplorer.Application")
    objIE.navigate "about:blank"
    objIE.Visible = True
    Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
    '~~> Indicates that page that will receive the request and the type of request being submitted
    xmlhttp.Open "POST", "http://www.craft-e-corner.com/addtocart.aspx?returnurl=showproduct.aspx%3fProductID%3d2688%26SEName%3dnew-testament-cricut-cartridge", False
    '~~> Indicate that the body of the request contains form data
    xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    '~~> Send the data as name/value pairs
    xmlhttp.Send "Quantity=1&VariantID=2705&ProductID=2688"
     response = xmlhttp.responseText
    objIE.Document.Write response
    Set xmlhttp = Nothing
End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top