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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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