Excel VBA IE querySelector button click

141 Views Asked by At

Trying to click button using IE. Button

Due to the firm policy Selenium Basic, is banned. So using that route is not possible.

getting error Object variable not set (Error 91)

code till now.

Global driver As Object
Dim html As HTMLDocument

Set driver = CreateObject("InternetExplorer.Application")
with driver
    Const Url$ = "My URL"
         .Visible = True
         .Navigate Url
Set hmtl = .Document
    Do
      DoEvents
    Loop Until .ReadyState = 4
    html.queryselector("input#btnFilter").Click
end with

while using Selenium I was able to click it without problems, also tried it like this

driver.Document.getElementsByClassname("objectButton")(1).Click

which does not yield error, but looks like it freezes the page, if I do it manually, it works fine.

1

There are 1 best solutions below

1
Daniel On

There is no click event in the button html. Probably there is a click event on the class or the section or the document. I don't know if this click event is triggered when you click on the button by vba code. Try to find the click event and trigger it directly. For the button you can also use GetelementbyId("btnFilter"). But probably it will no trigger the click function.