I'm trying to "click" on a image that right after a click, execute a function. I tried two things:
Private Sub Anbima()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application") IE.Visible =
True IE.navigate
"https://www.anbima.com.br/pt_br/informar/taxas-de-titulos-publicos.htm"
Do Loop Until IE.ReadyState = READYSTATE_COMPLETE
Application.Wait (Now + TimeValue("0:00:05"))
IE.document.querySelector("img[name='Consultar']").Click
End Sub
But this one gives me Runtime Error 424" error with message "Object Required".
After that I tried to directly run the function:
Private Sub Anbima()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application") IE.Visible =
True IE.navigate
"https://www.anbima.com.br/pt_br/informar/taxas-de-titulos-publicos.htm"
Do Loop Until IE.ReadyState = READYSTATE_COMPLETE
Application.Wait (Now + TimeValue("0:00:05"))
Call IE.document.parentWindow.execScript("SubmitAction()")
End Sub
But this also, give a Runtime Error '-2147352319 (80020101)': Error 80020101
Here is the HTML code:
<img src="../img/bt_consultar.gif" name="Consultar" onclick="SubmitAction()" style="cursor: pointer;">
Would you kindly help me ?