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.
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