自动化错误:被调用的对象与客户端断开连接

我所做的只是将一段代码完全正确地复制到另一个子文件中,然后更改我想要导航的URL。 第一个分组仍然有效,但第二个分组没有。 我很难过

Dim ie As InternetExplorer Dim html As HTMLDocument Set ie = New InternetExplorer ie.Visible = False ie.navigate "http://cesp.hma.eu/Contacts" With ie Do Until .READYSTATE = 4: DoEvents: Loop Do While .Busy: DoEvents: Loop End With Set html = ie.document Set ie = Nothing Application.StatusBar = "" 

使用F8逐步检查代码,似乎URL忽略ie.Visible = False (它打开时,我到达With ie ),然后使错误popup的Do While .Busy: DoEvents: Loop

我真的不知道从哪里开始寻找解决这个问题,因为我从字面上只改变了url,没有别的。 我最好的select就是closures我的工作簿并重新打开它,但问题决定坚持下去。 任何提示,解释,或解决scheme,你可以拿出将不胜感激。

这可能与IE中的安全设置有关。 正如@ Vigneshts88 在这里所build议的,尝试改变

 Set ie = New InternetExplorer 

至:

 Set ie = New InternetExplorerMedium 

正如上面的答案中的@Mike所述, InternetExplorerMedium要求提供Microsoft Internet Controls

是的,宝贝!

设置ie =新InternetExplorerMedium

为我修好了!

等不及要把这个东西工作。