I am new to VBA and i have to select option 2 from a dropdown menu in one of the internet explorer pages of a specific website.
Here is a snapshot of the html code of the webpage.
I cannot figure out a way of accessing the dropdown option in VBA. I tried using this but ist doesn't seem to target the element i want.
Set objShell3 = CreateObject("Shell.Application")
IE_count = objShell3.Windows.Count
For x = 0 To (IE_count - 1)
On Error Resume Next
my_url = objShell3.Windows(x).document.Location
my_title = objShell3.Windows(x).document.Title
MsgBox ("The title of this page is: " & my_title)
If my_title Like "Export to Excel" & "*" Then
Set ie3 = objShell3.Windows(x).document
my_title3 = ie3.Title
MsgBox ("The title of Export to Excel is: " & my_title3)
Exit For
Else
End If
Next
For Each element In ie3.getElementsByTagName("a")
If element.innerText = "Option2" Then
element.Click
Exit For
Else
End If
Next
Is there any specific syntax to access the options of a dropdown menu in vba?
Thank you :)
See Question&Answers more detail:os