This is first time I am trying to extract an excel report from a webpage. Sequence of how my code should work is as under:
- Initial URL - brings home page of the website (userid and password saved in browser to autologin) - image1
- Click on "Reports"
- New page appears (image2)
- select from dropdown_module.
- Select appropriate from dropdown_reports.
- selection in dropdown_reports creates a new dropdown_project.
- select from dropdown_project
- click on drownload reports (image3)
give path for downloading.
I am able to reach upto point 3, but not able to proceed ahead. On using inspect element on dropdown_module i get the code (image4)
My using so far is as under:
Set IE = CreateObject("InternetExplorer.Application")
URL = Range("hr_url").Value
IE.Visible = True
IE.navigate URL
Application.StatusBar = " is loading. Please wait..."
Do While IE.readyState = 4: DoEvents: Loop
Do Until IE.readyState = 4: DoEvents: Loop
Application.StatusBar = " Loaded"
Set doc = IE.document
For Each element In doc.all
If InStr(element.ID, "08191") > 0 Then
If InStr(element.ID, "AppPress:12") Then
element.Focus
element.Click
End If
End If
Next element
Application.Wait (5)
Do
DoEvents
Loop Until IE.readyState <> 4
Set doc = IE.document
For Each element In doc.all
If InStr(element.ID, "0261") > 0 Then
If InStr(element.ID, "AppPress:6") Then
MsgBox "element is found"
element.Options(0).Selected = True
End If
End If
Next element
The code isnt able to find the dropdown element and select the 0 index required. Can anyone suggest what is wrong here?