blackorchids2002
Board Regular
- Joined
- Dec 29, 2011
- Messages
- 138
Hi Masters,
I have my code running well in logging into a webpage that requires a login, setting my parameters and filtered the queried data.The only missing part is how to code to export the data in excel.
The webpage has an excel icon to click where it enables you to export the data queried. In this part, I really don't know how to code that to export the data and save it into xls or xlsx format.
Here is the HTML code that I got in inspecting the element in the webpage.
[<img alt="Export to Excel" src="//shipcdn.com/Assets/Excel-icon.png" border="0" complete="complete"/>][/HTML]
[<a href="/Bizdesk/excelExport.aspx?new=excel" target="_blank">][/HTML]
In my code below, they are okay and the missing part of the code is to export the data into excel.
Sub GetINTdata()
Dim ieApp As InternetExplorer
Dim ieDoc As Object
'create a new instance of ie
Set ieApp = New InternetExplorer
'you don’t need this, but it’s good for debugging
ieApp.Visible = True
'assume we’re not logged in and just go directly to the login page
ieApp.Navigate "http://www.intexpress.com/BizDesk/Login.aspx"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
Set ieDoc = ieApp.Document
'fill in the login form – View Source from your browser to get the control names
With ieDoc.forms(0)
.ctl00_ContentPlaceHolder1_txtUsername.Value = "xxxx"
.ctl00_ContentPlaceHolder1_txtPassword.Value = "xxxx"
.ctl00_ContentPlaceHolder1_btnSubmit.Click
End With
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
'now that we’re in, go to the page we want
ieApp.Navigate "http://www.intexpress.com/BizDesk/AWBReport.aspx"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
'fill in the parameters of the report and filter then export the data
With ieDoc.forms(0)
'Account
.ctl00_ContentPlaceHolder1_txtFilterAccount.Value = ""
'AWB#
.ctl00_ContentPlaceHolder1_txtFilterAWBNumber.Value = ""
'Sender State
.ctl00_ContentPlaceHolder1_drpFirstSenderState.Value = "CA"
'Reciever State
.ctl00_ContentPlaceHolder1_drpFirstRecipientState.Value = "GA"
'Start Date (From)
.ctl00_ContentPlaceHolder1_txtFilterStartDate.Value = "07/01/2015"
'End Date (To)
.ctl00_ContentPlaceHolder1_txtFilterEndDate.Value = "07/08/2015"
'Filter Button
.ctl00_ContentPlaceHolder1_btnFilter.Click
End With
End Sub
I would really appreciate your help on this.
Thanks,
blackorchids
I have my code running well in logging into a webpage that requires a login, setting my parameters and filtered the queried data.The only missing part is how to code to export the data in excel.
The webpage has an excel icon to click where it enables you to export the data queried. In this part, I really don't know how to code that to export the data and save it into xls or xlsx format.
Here is the HTML code that I got in inspecting the element in the webpage.
[<img alt="Export to Excel" src="//shipcdn.com/Assets/Excel-icon.png" border="0" complete="complete"/>][/HTML]
[<a href="/Bizdesk/excelExport.aspx?new=excel" target="_blank">][/HTML]
In my code below, they are okay and the missing part of the code is to export the data into excel.
Sub GetINTdata()
Dim ieApp As InternetExplorer
Dim ieDoc As Object
'create a new instance of ie
Set ieApp = New InternetExplorer
'you don’t need this, but it’s good for debugging
ieApp.Visible = True
'assume we’re not logged in and just go directly to the login page
ieApp.Navigate "http://www.intexpress.com/BizDesk/Login.aspx"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
Set ieDoc = ieApp.Document
'fill in the login form – View Source from your browser to get the control names
With ieDoc.forms(0)
.ctl00_ContentPlaceHolder1_txtUsername.Value = "xxxx"
.ctl00_ContentPlaceHolder1_txtPassword.Value = "xxxx"
.ctl00_ContentPlaceHolder1_btnSubmit.Click
End With
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
'now that we’re in, go to the page we want
ieApp.Navigate "http://www.intexpress.com/BizDesk/AWBReport.aspx"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
'fill in the parameters of the report and filter then export the data
With ieDoc.forms(0)
'Account
.ctl00_ContentPlaceHolder1_txtFilterAccount.Value = ""
'AWB#
.ctl00_ContentPlaceHolder1_txtFilterAWBNumber.Value = ""
'Sender State
.ctl00_ContentPlaceHolder1_drpFirstSenderState.Value = "CA"
'Reciever State
.ctl00_ContentPlaceHolder1_drpFirstRecipientState.Value = "GA"
'Start Date (From)
.ctl00_ContentPlaceHolder1_txtFilterStartDate.Value = "07/01/2015"
'End Date (To)
.ctl00_ContentPlaceHolder1_txtFilterEndDate.Value = "07/08/2015"
'Filter Button
.ctl00_ContentPlaceHolder1_btnFilter.Click
End With
End Sub
I would really appreciate your help on this.
Thanks,
blackorchids