Selecting a dynamic drop down list on a web page using VBA

Abhijyot

New Member
Joined
Apr 27, 2014
Messages
2
I am trying to automate data download from FFIEC website using VBA. I am not able to make a selection in the dropdown list "Reporting Period End Date or Year" on the webpage using the following code. The dropdown list gets updated based on selection you make on the ListBox1 above it. Would really appreciate if someone could help me solve this. Thanks
Link to the website: Download Bulk Data - FFIEC Central Data Repository's Public Data Distribution

VBA Code:
Sub DownloadDataFromFFIEC()

Dim DefPath As String
Dim dropOption As MSHTML.IHTMLElement
Dim IE As New SHDocVw.InternetExplorer
Dim HTMLDoc As MSHTML.HTMLDocument
Dim HTMLInput As MSHTML.IHTMLElement
IE.Visible = True
IE.Navigate2 "https://cdr.ffiec.gov/public/PWS/DownloadBulkData.aspx"
Do While IE.ReadyState <> READYSTATE_COMPLETE
'DefPath = ThisWorkbook.Worksheets("Sheet1").Cells(5, 4)
Loop
Dim options As Object, i As Long, found As Boolean
Set HTMLDoc = IE.Document
Set HTMLInput = HTMLDoc.getElementById("ListBox1")
HTMLInput.Value = "ReportingSeriesSinglePeriod"
Set HTMLInput = HTMLDoc.getElementById("TSVRadioButton")
HTMLInput.Checked = "Checked"
Set HTMLInput = HTMLDoc.getElementById("DatesDropDownList")
For i = 1 To HTMLInput.options.Length
    Debug.Print HTMLInput.options
    'If HTMLInput.options(i).Text = DefPath Then
    If HTMLInput.options(i).Text = "12/31/2019" Then
        HTMLInput.selectedIndex = i
        Exit For
    End If
Next i

Set HTMLInput = HTMLDoc.getElementById("Download_0")
HTMLInput.Value = "Download"
HTMLInput.Click
Debug.Print IE.LocationName, IE.LocationURL
End Sub '''
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,223,270
Messages
6,171,102
Members
452,379
Latest member
IainTru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top