尝试运行一些简单的代码,只是打开一个网站。但是,请继续获取Automation Error: The object invoked has disconnected from its clients
。下面的代码。代码调试器跳至突出显示Do While oIE.ReadyState <> 4
Sub test()
Set oIE = CreateObject("InternetExplorer.application")
oIE.Visible = True
oIE.navigate ("https://www.google.com")
Do While oIE.ReadyState = 4: Application.Wait (Now + TimeValue("0:00:01")): Loop
Do While oIE.ReadyState <> 4: Application.Wait (Now + TimeValue("0:00:01")): Loop
' example ref to DOM
MsgBox oIE.Document.GetElementsByTagName("div").Length
End Sub