Trouble stopping a "Do Until" loop in Excel VBA -
so new issue cannot following code stop looping. seems though "do until element nothing" line may not accurate button attempting click not showing "nothing" value @ end of run. here code brief description of issue.
sub searchbot() dim objie internetexplorer dim y integer dim result string set objie = new internetexplorer objie.visible = true objie.navigate "https://www.searchiqs.com/nyalb/login.aspx" while objie.busy = true or objie.readystate <> 4: doevents: loop objie.document.getelementbyid("btnguestlogin").click while objie.busy = true or objie.readystate <> 4: doevents: loop objie.document.getelementbyid("contentplaceholder1_txtfromdate").value = "07/11/2017" objie.document.getelementbyid("contentplaceholder1_txtthrudate").value = "07/13/2017" objie.document.getelementbyid("contentplaceholder1_cbodocgroup").value = "dba" objie.document.getelementbyid("contentplaceholder1_cmdsearch").click while objie.busy = true or objie.readystate <> 4: doevents: loop y = 1 ' brings table of results. need click on view button , info page objie.document.getelementbyid("contentplaceholder1_grdresults_btnview_0").click while objie.busy = true or objie.readystate <> 4: doevents: loop ' element id's hidden looking result = trim(objie.document.getelementbyid("contentplaceholder1_lbldetails2").innertext) sheets("sheet1").range("a" & y).value = result 'sheets("sheet1").range("c" & y).value = result y = y + 1 ' love direct link next search result here link not change between pages click next button objie.document.getelementbyid("contentplaceholder1_btnnext").click while objie.busy = true or objie.readystate <> 4: doevents: loop while objie.busy = true or objie.readystate <> 4: doevents: loop ' believe issue occurs until objie.document.getelementbyid("contentplaceholder1_btnnext") nothing result = trim(objie.document.getelementbyid("contentplaceholder1_lbldetails2").innertext) sheets("sheet1").range("a" & y).value = result y = y + 1 ' when next page button visible, goes next page. when dimmed, code continues. doesn't stop unless manually stop it. takes final page , repeats process infinitely. objie.document.getelementbyid("contentplaceholder1_btnnext").click while objie.busy = true or objie.readystate <> 4: doevents: loop loop ' end few results in beginning , final result repeats until stop script. end sub
this html reading when button visible
<input name="ctl00$contentplaceholder1$btnnext" title="next document" id="contentplaceholder1_btnnext" style="width: 35px;" onclick="savedoclistselected();" type="submit" value=">>">
this html reading when button dimmed
<input name="ctl00$contentplaceholder1$btnnext" title="next document" disabled="disabled" class="aspnetdisabled" id="contentplaceholder1_btnnext" style="width: 35px;" type="submit" value=">>">
any appreciated.
Comments
Post a Comment