1

I'm trying to use VBA to navigate to a website and then extract some data. So far I've been able to navigate to the website and, but I can't figure out how to click on the buttons I need. Based on the research I've done, using querySelector is a much better option than using getElements.

When I inspect the button I'm trying to click on it brings me to the following line in IE's DOM explorer

<INPUT width="80" class= "button" onclick= "updateSummary();"  type= "button" value="Apply Filters"></input>

Based on my research, I've got the following: . . .

Ie.document.queryselector("input[value=Apply Filters]") (0).click

But I get a

runtime '438' object doesn't support this property or method.

I'd also like to be able to click on an "Export to CSV" button, and the html code has an href component and a source = "dynamically changing code based on the day" component.

Would it be possible to click on the export to to CSV button and either open the file or save it in a folder?

Thanks so much for the help!

4
  • may not be applicable, but strictly speaking, that's not valid HTML for the input definition. Commented Dec 7, 2018 at 17:17
  • 1
    document.queryselector returns either a single element or null if there's no match. So try dropping the (0) Commented Dec 7, 2018 at 17:29
  • Please ask a new question and include the relevant html for your second question. Commented Dec 7, 2018 at 17:55
  • If the object of clicking the button is to run the updateSummary() script, have you tried the execScript method to run it directly? Commented Dec 7, 2018 at 18:44

1 Answer 1

1

Two things:

  1. As mentioned in comments, drop the zero as you are not dealing with a nodeList. querySelector returns a single node which is the first match for the specified selector, or null.

  2. You cannot pass a selector for attribute value that contains spaces without enclosing within ''

    ie.document.querySelector("[value='Apply Filters']")
    

You could also use:

ie.document.querySelector("[onclick='updateSummary();']")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.