Alien_Explorer
Alien_Explorer

Reputation: 867

VBA to checkbox on IE

I'm unable to tick/click checkbox on IE (through VBA) and it seems I have tried a lot of methods already. Can you please advise?

FYI Elements:

<div class="bordered_table" id="mig-to-prod">
    <div class="edl_checkbox floatleft">

            <input type="hidden" name="_selectAllConfigs" value="visible" />    
            <label class="edl_chb">         
                <input type="checkbox" name="selectAllConfigs"

                onclick="changeDropDown(this.form);">
                <span></span>   

The checkbox is edl_chb

I have tried:

Html.querySelector("a[title=edl_chb]").Click
Html.querySelector("a[title='edl_chb']").Click
Html.querySelector("a[title='edl_chb']")(0).Click
Html.querySelector("a[title='edl_chb']")(1).Click

I have also tried to getelemtsbyclassname

Upvotes: 1

Views: 361

Answers (1)

QHarr
QHarr

Reputation: 84465

Be sure to allow enough time for page to load. This includes having the following after the .Navigate2 line.

While ie.Busy Or ie.readyState < 4: DoEvents: Wend

For other approaches see here.

You could try an attribute = value combination of

ie.document.querySelector("[type=checkbox][name=selectAllConfigs]").click

Or

ie.document.querySelector("[type=checkbox][name=selectAllConfigs]").FireEvent "onclick"

Upvotes: 1

Related Questions