0

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 ?

QHarr
  • 83,427
  • 12
  • 54
  • 101
  • It is inside an `iframe`. Instead navigate direct to the `iframe` `src` with _ie.Navigate2 "https://www.anbima.com.br/informacoes/merc-sec/default.asp"_ then have your page load code and then attempt the click on your element. You may need to trigger the attached onclick. Or use your execScript method. – QHarr May 20 '20 at 21:30
  • @QHarr Thanks ! It worked really fine. Could please tell me where did you find this link: https://www.anbima.com.br/informacoes/merc-sec/default.asp ? – Gabriel Cassagni May 21 '20 at 01:26
  • You could use F12 dev tools to check the source code of the page. Then you could find the link in the ` – Yu Zhou May 21 '20 at 03:39
  • @YuZhou Amazing Yu Zhou ! Thank you ! – Gabriel Cassagni May 21 '20 at 13:51

0 Answers0