问题描述
在调用以下对象时,我收到一个自动化错误
I am getting the an automation error while invoking the following object
Set IE = CreateObject("InternetExplorer.Application")
错误显示
运行时错误'-2147467259(80004005)'
自动化错误
未指定错误
任何人都可以了解为什么正在发生
Can anyone have any idea why this is occuring
'从评论中移动代码
Sub TableExample()
Dim IE As Object
Dim doc As Object
Dim strURL As String
strURL = Range("B2").Value
Set IE = CreateObject("InternetExplorer.Application")
With IE '
.Visible = True
.navigate Range("B2").Value
Do Until .readyState = 4
DoEvents
Loop
Do While .Busy
DoEvents
Loop
Set doc = IE.document
GetAllTables doc
.Quit
End With
End Sub
推荐答案
我只是浪费了4个小时的时间,而且我很乐意解决这个问题。
每次运行行时,Excel会创建一个新的activeX实例:
I just wasted 4 hours on this, and I'm facepalming at how easy the solution was.Excel creates a new activeX instance every time you run the line:
Set IE = CreateObject("InternetExplorer.Application")
这个工作原理是在我的联盟之外, Excel中。经过几十个堆积,excel的内存不足以使更多的
How exactly that works is out of my league, but those references stick around even after you restart excel. After a couple dozen pile up, excel runs out of memory to make more
重新启动计算机(可能是一个更简单的方法,但对我有用)
然后坚持线路
Restart your computer, (probably an easier way, but that worked for me)and then stick the line
IE.Quit
在代码末尾
这篇关于CreateObject中的VBA自动化错误(“InternetExplorer.Application”)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!