[基本上,我的代码打开并登录到网页,然后单击按钮导航到新屏幕。加载完此新屏幕后,我们尝试单击上述引发错误的按钮。
Sub Website()
Dim ie_Obj As InternetExplorer
Set ie_Obj = New InternetExplorer
ie_Obj.Visible = True
ie_Obj.navigate "https://www.websitehere.omitted/"
Do While ie_Obj.Busy = True Or ie_Obj.readyState <> 4: DoEvents: Loop
ie_Obj.Document.getElementById("LoginBtn").Click ' This one works fine. What's wrong with the next one?
Do While ie_Obj.Busy = True Or ie_Obj.readyState <> 4: DoEvents: Loop
Application.Wait (Now + TimeValue("0:00:05")) ' I added this to allow the page to load.
ie_Obj.Document.getElementById("chkAllrlbLocs").Click' <--- Code breaks here
'... more code follows
我知道原因之一可能是因为页面尚未完成加载;但是,如果我逐行使用F8并允许其加载,它仍然会引发错误。
这是我的HTML:
<input name="chkAllrlbLocs" tabindex="-1" id="chkAllrlbLocs" onclick="if (! SelectAllLBItems('rlbLocs')) return false;setTimeout('__doPostBack(\'chkAllrlbLocs\',\'\')', 0)" type="checkbox">
[当我尝试getElementById时,将引发运行时错误424。基本上,我的代码将打开并登录到网页,然后单击按钮导航到新屏幕。载入新屏幕后,我们尝试...