excel - VBA Internet Explorer 自动化错误
问题描述
我试图建立一个公共测试环境,看看是否有人能帮助我解决我今天早上问的另一个问题,我得到了这个错误,我没有在我的原始代码中得到这个错误,在浏览了一下之后我无法修复:自动化错误 - 调用的对象已与其客户端断开连接。
这是完整的代码:
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
任何人都知道如何解决这个问题?
解决方案
使用后期绑定来避免对库的额外引用,这将解决版本控制问题(如果有)。
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
推荐阅读
- javascript - 当 `label` 元素包含子 `span` 时,单击标签会触发子元素而不是父元素
- r - 计算复制的平均值
- flutter - 如何制作带有一行的列表构建器
- php - 将 Carbon 日期转换为 html 日期时间格式
- mysql - SQL - 选择所有行并仅计算大于 1 的列
- excel - Excel 中对 Sharepoint 上其他工作簿的单元格引用/公式不会更新值
- c++ - 如何在 C++ 中创建我自己的循环版本?
- javascript - 将 Firebase Cloud Function TypeScript 语法转换为 JavaScript
- python - BeautifulSoup 请求失败
- c++ - 我是否需要为仅传递给模板化函数的类声明 __declspec(dllexport)?