xmlHttp Post in VBA from ASP Query?


New Member
Jun 8, 2015
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.

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

Some videos you may like

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


New Member
Jun 8, 2015
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?

Watch MrExcel Video

Forum statistics

Latest member

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...