在调用以下对象时,我得到了一个自动化错误
Set IE = CreateObject("InternetExplorer.Application")
错误正在显示
运行时错误'-2147467259 (80004005)‘自动化错误未指定错误
有人知道为什么会发生这种事吗?
从注释中移出代码
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
发布于 2014-09-09 04:23:15
我只是在这上面浪费了4个小时,我正在面对这个解决方案是多么容易。Excel每次运行该行时都会创建一个新的activeX实例:
Set IE = CreateObject("InternetExplorer.Application")
这到底是如何工作是超出我的范畴,但这些参考仍然存在,即使在你重新启动excel。经过几十次堆积如山后,excel耗尽了内存来制造更多。
重新启动您的计算机(可能是一种更简单的方法,但对我有效),然后坚持下去。
IE.Quit
在代码的末尾
发布于 2016-11-10 19:58:17
对于那些以同样的错误来到这里的人来说.
这也可能是由于引用已退出并设置为空的Document
对象中的InternetExplorer
对象属性造成的。这不是问题中正在发生的情况,但是下面的代码会引发相同的错误。
Dim ie As New InternetExplorer
ie.Visible = True
ie.Navigate "google.com"
ie.Quit
Set ie = Nothing
If ie.Document Is Nothing Then 'Error thrown here
MsgBox "Can't get here"
End If
发布于 2020-10-19 00:49:27
添加代码以确保所有IE浏览器在设置行之前完全关闭。
Set IE = CreateObject("InternetExplorer.Application")
改为:
调用IE_Sledgehammer
设置IE = CreateObject("InternetExplorer.Application")
在工作簿中的其他地方添加Sledge锤模块作为自己的宏:
亚IE_Sledgehammer()
Dim objWMI为对象,objProcess为对象,objProcesses为对象
Set objWMI = GetObject("winmgmts://.")
Set objProcesses = objWMI.ExecQuery( \_
"SELECT \* FROM Win32\_Process WHERE Name = 'iexplore.exe'")
For Each objProcess In objProcesses
On Error Resume Next
Call objProcess.Terminate
Next
设置objProcesses = Nothing: Set objWMI = Nothing
结束子对象
https://stackoverflow.com/questions/22061833
复制相似问题