VBA:访问IE的“ Do While”时出现自动化错误

时间:2019-10-22 13:49:22

标签: excel vba internet-explorer

尝试运行一些简单的代码,只是打开一个网站。但是,请继续获取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


0 个答案:

没有答案