I am creating a macro to grab Fax Numbers from a public banking website.
I have written enough code to get to the site, select from a dropdown list, and change the selection in the dropdown list. However when I use FireEvent ("onChange"), it does not trigger the webpage to update.
I have searched for an answer, but have not found any.
Website: https://www.atb.com/contact-us/Pages/branch-locator.aspx
Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
Sub test()
Dim ieExplorer As New InternetExplorerMedium
Dim ieField As Object
Dim ieSubmit As Object
Dim ieSelect As Object
Dim iebutton As Object
Dim buttCounter As Integer
Dim objOption As Object
Dim objCount As Integer
Dim ieForm As Object
Dim intRow As Long, faxNum As String
intRow = 2
With ieExplorer
.Visible = True
.Navigate "https://www.atb.com/contact-us/Pages/branch-locator.aspx"
Sleep 1000
Sleep 1000
Sleep 1000
Sleep 1000
Sleep 1000
Sleep 1000
Sleep 1000
Set ieSelect = .Document.getElementsByTagName("select")
Do While o < ieSelect.Length
If ieSelect(o).ID = "ba" Then
For Each i In ieSelect(o).Options
If i.Value <> "null" Then
ieSelect(o).Focus
i.Selected = True
ieSelect(o).FireEvent "onchange"
Set ieField = .Document.getElementsByTagName("p")
Do While x < ieField.Length
If InStr(ieField(x).innertext, "FAX") Then
Cells(intRow, "A").Value = i.Value
Cells(intRow, "B").Value = ieField(x).innertext
intRow = intRow + 1
End If
Loop
End If
Next
End If
o = o + 1
Loop
End With
End Sub