vba - My excel macro generates errors inconsistently -
i working on macro automate web browser stuff , there intermittent runtime error 91 "object variable or block variable not set". have been playing around how declare , create browser object nothing working.
sub morning_script() dim webbrowser object set webbrowser = new internetexplorermedium webbrowser.visible = true webbrowser.navigate "www.google.com" while webbrowser.busy = true doevents wend webbrowser.document.getelementbyid("lst-ib").value = "test" 'webbrowser.document.getelementbyid("verify").value = worksheets("sheet1").range("b2") 'webbrowser.document.getelementbyid("institution").value = "xxx" 'worksheets("sheet1").range("b1").clear 'worksheets("sheet1").range("b2").clear end sub
the url has been changed public website , form entry has been commented out now.
if prefer avoid fixed timers, try one:
dim objelement object: set objelement = nothing while objelement nothing set objelement = webbrowser.document.getelementbyid("lst-ib") doevents wend objelement.value = "test"
if refer verify , institution to, have implement scheme them, , wait until 3 variables non-nothing. may want set timeout or maximum retry number if there great number of pages download.
Comments
Post a Comment