0

I am trying to create an IE automation to select the correct item from a dropdown check list. All items are set to automatically be checked when the site starts up. I am having difficulty getting any of the boxes I don't need to uncheck. Here is the html code

<div id="ReportViewerControl_ctl04_ctl07_divDropDown" onclick="event.cancelBubble=true;" onactivate="event.cancelBubble=true;" style="display:inline-block;border-color:DarkGray;border-width:1px;border-style:Solid;overflow:auto;background-color:window;display:none;position:absolute;z-index:11;"> <table cellpadding="0" cellspacing="0" style="background-color:window;"> <tr> <td nowrap="nowrap"><span><input id="ReportViewerControl_ctl04_ctl07_divDropDown_ctl00" type="checkbox" name="ReportViewerControl$ctl04$ctl07$divDropDown$ctl00" checked="checked" onclick="$get('ReportViewerControl_ctl04_ctl07').control.OnSelectAllClick(this);" /><label for="ReportViewerControl_ctl04_ctl07_divDropDown_ctl00">(Select All)</label></span></td> </tr><tr> <td nowrap="nowrap"><span><input id="ReportViewerControl_ctl04_ctl07_divDropDown_ctl02" type="checkbox" name="ReportViewerControl$ctl04$ctl07$divDropDown$ctl02" checked="checked" onclick="$get('ReportViewerControl_ctl04_ctl07').control.OnValidValueClick(this, 'ReportViewerControl_ctl04_ctl07_divDropDown_ctl00');" /><label for="ReportViewerControl_ctl04_ctl07_divDropDown_ctl02">Shift&nbsp;1</label></span></td> </tr><tr> <td nowrap="nowrap"><span><input id="ReportViewerControl_ctl04_ctl07_divDropDown_ctl03" type="checkbox" name="ReportViewerControl$ctl04$ctl07$divDropDown$ctl03" checked="checked" onclick="$get('ReportViewerControl_ctl04_ctl07').control.OnValidValueClick(this, 'ReportViewerControl_ctl04_ctl07_divDropDown_ctl00');" /><label for="ReportViewerControl_ctl04_ctl07_divDropDown_ctl03">Shift&nbsp;2</label></span></td> </tr><tr> <td nowrap="nowrap"><span><input id="ReportViewerControl_ctl04_ctl07_divDropDown_ctl04" type="checkbox" name="ReportViewerControl$ctl04$ctl07$divDropDown$ctl04" checked="checked" onclick="$get('ReportViewerControl_ctl04_ctl07').control.OnValidValueClick(this, 'ReportViewerControl_ctl04_ctl07_divDropDown_ctl00');" /><label for="ReportViewerControl_ctl04_ctl07_divDropDown_ctl04">Shift&nbsp;3</label></span></td> </tr> </table><span><input type="hidden" name="ReportViewerControl$ctl04$ctl07$divDropDown$ctl01$HiddenIndices" id="ReportViewerControl_ctl04_ctl07_divDropDown_ctl01_HiddenIndices" value="0,1,2" /></span> </div><iframe id="ReportViewerControl_ctl04_ctl11_ctl01" onclick="event.cancelBubble=true;" onactivate="event.cancelBubble=true;" 

Here is what I have tried to do:

Do DoEvents Loop Until ieObj.readyState = 4 ieObj.document.getElementById("ReportViewerControl_ctl04_ctl07_divDropDown_ctl02").Checked = "Unchecked" 

The box for this element remains unchanged. Any suggestions on how to change this would be greatly appreciated. Thank you in advance.

1
  • ieobject.document.querySelector("#ReportViewerControl_ctl04_ctl07_divDropDown_ctl00").click first? Commented Apr 14, 2020 at 14:44

1 Answer 1

1

You should set the checked value to False to make it unchecked.

The sample code is like this:

Sub LOADIE() Set ieA = CreateObject("InternetExplorer.Application") ieA.Visible = True ieA.navigate "http://www.example.com" Do Until ieA.readyState = 4 DoEvents Loop ieA.document.getElementById("ReportViewerControl_ctl04_ctl07_divDropDown_ctl02").Checked = False End Sub 

The result is like this:

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

thanks for the quick response, however when i make this change the boxes still show up as marked. Is it because of the “select all” option that controls the other boxes? I cannot manipulate that box either bc it does not a CHECKED variable.
It might be. You could try to click the "select all" option first like @QHarr suggested in the comment.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.