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
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 '''