Click on Button with VBA

Asked

Viewed 1,197 times

0

Good morning,

I have a macro that accesses a site, enters the data and performs research, but I’m not able to make you click the "Query" button, could anyone help? Follows page HTML and macro code;

<div class="row">
                        <div class="col-md-4 col-xs-12">    
                            <div class="form-group">
                                <button class="btn btn-primary btn-sm" onclick="check()"><i class="fa fa-search"></i> Consultar</button>
                            </div>              

Macro

'Carrega os dados de CEP e NUM na página e pesquisa os dados informados
    IE.Document.all("numero-logradouro-ins").Value = lNUM
    IE.Document.all("cep-ins").Value = lCEP
    For Each Button In IE.Document.getElementsByTagName("btn btn-primary btn-sm") 'FAILED
Button.Click
    Next

Thank you!

  • See if you don’t need to trigger the event onclick(). The answer to this link provides an example for the onchange event.

  • 1

    @danieltakeshi turned out I didn’t even have to call event, as the button is a class I just changed getElementTagName to getElementsByClassName("btn-Primary btn-Sm") with the name of the button class, gave it right! Thanks for the attention, hugs!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.