I get two different errors on the same line. Sometimes this one:
Automation error: object invoked has disconnected from its clients
and sometimes:
the interface is unknown
Minimal code to reproduce error:
Sub mcve()
Dim ie As Object
Dim www As String
Set ie = New InternetExplorerMedium
www = "http://www.stackoverflow.com"
ie.navigate www
ie.Visible = False
While ie.ReadyState <> 4 ' <~~~~~~~~~~~~~~~~~~~~~~~~ Error occurs here
DoEvents
Wend
End Sub
This requires a reference: Tools > References... > Microsoft Internet Controls
The error occurs on While ie.ReadyState <> 4
the second time. How do I fix this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…