简体   繁体   中英

VBA Internet explorer Automation error

I was trying to set up a public test environment to see if anyone would be able to help me with another question I asked this morning and I'm getting this error which I was not getting in my original code and after browsing a bit around I cannot fix: Automation error - The object invoked has disconnected from its clients .

自动化错误-调用的对象已与其客户端断开连接

Here is the full code:

Sub GetBranches()
    Dim objIE As InternetExplorer
    Set objIE = New InternetExplorerMedium ' create new browser

    objIE.Visible = True

    objIE.navigate "https://casadasereia.net/vbatests/viewtree241653.html"

    ' wait for browser
    Do While objIE.Busy = True Or objIE.readyState <> 4
        DoEvents
    Loop
End Sub

Anyone knows how to fix this?

Use late-binding to avoid additional reference to a library and this will fix versioning issues if any.

Sub GetBranches()
    Dim objIE as Object 
    Set objIE = CreateObject("InternetExplorer.Application")

    objIE.Visible = True

    objIE.navigate "https://casadasereia.net/vbatests/viewtree241653.html"

    ' wait for browser
    Do While objIE.Busy = True Or objIE.readyState <> 4
        DoEvents
    Loop
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM