xmlHttp Post in VBA from ASP Query?

mrlemmer11

New Member
Joined
Jun 8, 2015
Messages
32
Good Afternoon,

I have been trying to no avail to get a VBA script to tunnel to my corporate reports viewer which is ASP I believe, choose a drop down choice, enter in a SKU and run the query. I have been able to successfully do it when I have VBA launch and IE window for me, but that process takes 70+ hours to go through all 47,500 skus I need to get data from. I am open to either scraping the results of the query, or I don't mind downloading a CSV for each sku and then merging all 47,500 CSV's into one sheet. With this being said, I just don't know how to make the xmlHttp method to work. Please let me know if you need any further information from me or anything I can do to assist in you helping me with this issue.

The results from this which is entered into cell(1,1) is simply showing the corporate report sites normal HTML data and nothing specific to return results when I run this.

Code:
Public Sub openWebsite(strOpenMethod As String, strURL As String, Optional strPostData As String)    Dim ws As Worksheet
    Dim pXmlHttp As Object
    Set pXmlHttp = CreateObject("MSXML2.XMLHTTP")
    Set ws = ThisWorkbook.Worksheets("Sheet5")
    pXmlHttp.Open strOpenMethod, strURL, False
    pXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    pXmlHttp.send (strPostData)




    Dim pHtmlObj As Object
    Set pHtmlObj = CreateObject("htmlfile")
    pHtmlObj.body.innerHTML = pXmlHttp.responseText
    'MsgBox pXmlHttp.responseText
    ws.Cells(1, 1) = pXmlHttp.responseText


End Sub


Sub test()
    Dim ws As Worksheet
    Dim btnSearch As String, strSearchType As String, strSearchName As String, PostData As String
    Set ws = ThisWorkbook.Worksheets("Sheet5")
    btnSearch = "View Report"
    strSearchType = "SKU"
    strSearchName = "889506830"
    PostData = "ctl32_ctl04_ctl03_ddValue=" & strSearchType & "&ctl32_ctl04_ctl05_txtValue=" & strSearchName & "&ctl32_ctl04_ctl00=" & btnSearch
    ws.Cells(2, 1) = PostData
    openWebsite "POST", "http://***************/Reports/Pages/Report.aspx?ItemPath=%2fMail+Order%2fItem%2fExpanded+Item+Lookup", PostData
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Please, I'm stuck until I get understand this. I searched and tried all sorts of variations of this, but none of it is working. I simply can not get the drop down to select SKU, have a SKU number entered into the next field and hit submit when I am using xmlHttp. What am I doing wrong?
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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