【发布时间】:2017-11-09 01:59:22
【问题描述】:
Sub InternetPractice()
Dim ie As InternetExplorer
Set ie = New InternetExplorer
ie.Visible = True
ie.navigate "https://www.yahoo.com"
Do While ie.Busy = True Or ie.readyState <> 4: DoEvents: Loop
ie.document.getElementById("uh-search-box").Value = "Earth"
ie.document.getElementById("uh-search-button").Click
Do While ie.Busy = True Or ie.readyState <> 4: DoEvents: Loop
ie.document.getElementById("logo").Click
Set ie = Nothing
End Sub
代码在我逐行执行时有效,但在正常运行时无效。我尝试在某些部分插入长达 45 秒的休息时间,但没有成功。
正常运行,在ie.document.getElementById("logo").Click期间代码中断并给我一个
'424'对象需要错误
【问题讨论】:
-
那么当你正常运行的时候,有没有出现什么情况?
-
加载雅虎搜索后出现“424”对象所需的运行时错误
-
考虑使用更好的 API:stackoverflow.com/a/17481643/1188513
-
感谢您的建议。我对此并不熟悉,但它似乎要快得多。我得去看看!
标签: html vba excel internet-explorer