CodeNinja
07-24-2012, 02:33 PM
I am trying to pull a series of reports from the web using VBA.
I have successfully logged on to the account, navigated to where I see the report button, now I need to figure out the element I need to click to open the report and how to save the report to my hard drive.
Attached is a screen shot of the web page...
I am trying to "Click" on the summary report in the upper right corner...
Attached is the page source.
I would also like to be able to "click" on the July 09,2010 tab and click the same summary report.
Once I figure all this out, I believe I can do everything else I need.
Thanks for your help...
The code I am using to log on etc is as follows (I have deleted the password/username etc):
Sub test()
Dim Doc As HTMLDocument
Dim ie As InternetExplorer
Dim loginForm As HTMLFormElement
Dim usernameInputBox As HTMLInputElement
Dim passwordInputBox As HTMLInputElement
Dim signinbutton As HTMLImg
Dim sURL As String
sURL = "test2.hyattselectreports.lraqa.com/" '"https://test2.lraqa.com/"
Set ie = New InternetExplorer
ie.navigate sURL
ie.Visible = True
While ie.Busy
DoEvents
Wend
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
Set Doc = ie.document
On Error Resume Next
Set loginForm = Doc.forms(0)
Set usernameInputBox = loginForm.elements("username")
usernameInputBox.Value = "" 'I have deleted this for security reasons
Set passwordInputBox = loginForm.elements("password")
passwordInputBox.Value = "" 'I have deleted this for security reasons
loginForm.elements("LoginButton").Click
Do While ie.readyState <> READYSTATE_COMPLETE Or ie.Busy
DoEvents
Loop
'************************************************************************** *****
' will have to loop through all properties listed in a column on sheet 1 or so *
'************************************************************************** *****
ie.navigate "http://test2.hyattselectreports.lraqa.com/index.php?page=&propid=" & Sheet1.Cells(1, 1)
'I put 33808 in cell a1 ... I will do this as a loop and populate the appropriate cells with the property id's
Do While ie.readyState <> READYSTATE_COMPLETE Or ie.Busy
DoEvents
Loop
'need code here to "click" on the summary report button to navigate to that page... Thanks!
End Sub
Thanks for any help/suggestions.
Josh / CodeNinja.
I have successfully logged on to the account, navigated to where I see the report button, now I need to figure out the element I need to click to open the report and how to save the report to my hard drive.
Attached is a screen shot of the web page...
I am trying to "Click" on the summary report in the upper right corner...
Attached is the page source.
I would also like to be able to "click" on the July 09,2010 tab and click the same summary report.
Once I figure all this out, I believe I can do everything else I need.
Thanks for your help...
The code I am using to log on etc is as follows (I have deleted the password/username etc):
Sub test()
Dim Doc As HTMLDocument
Dim ie As InternetExplorer
Dim loginForm As HTMLFormElement
Dim usernameInputBox As HTMLInputElement
Dim passwordInputBox As HTMLInputElement
Dim signinbutton As HTMLImg
Dim sURL As String
sURL = "test2.hyattselectreports.lraqa.com/" '"https://test2.lraqa.com/"
Set ie = New InternetExplorer
ie.navigate sURL
ie.Visible = True
While ie.Busy
DoEvents
Wend
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
Set Doc = ie.document
On Error Resume Next
Set loginForm = Doc.forms(0)
Set usernameInputBox = loginForm.elements("username")
usernameInputBox.Value = "" 'I have deleted this for security reasons
Set passwordInputBox = loginForm.elements("password")
passwordInputBox.Value = "" 'I have deleted this for security reasons
loginForm.elements("LoginButton").Click
Do While ie.readyState <> READYSTATE_COMPLETE Or ie.Busy
DoEvents
Loop
'************************************************************************** *****
' will have to loop through all properties listed in a column on sheet 1 or so *
'************************************************************************** *****
ie.navigate "http://test2.hyattselectreports.lraqa.com/index.php?page=&propid=" & Sheet1.Cells(1, 1)
'I put 33808 in cell a1 ... I will do this as a loop and populate the appropriate cells with the property id's
Do While ie.readyState <> READYSTATE_COMPLETE Or ie.Busy
DoEvents
Loop
'need code here to "click" on the summary report button to navigate to that page... Thanks!
End Sub
Thanks for any help/suggestions.
Josh / CodeNinja.