使用 Excel VBA 控制 Internet Explorer 本地 Intranet [英] Controlling Internet Explorer local intranet using Excel VBA
问题描述
我正在使用 Excel VBA 代码单击我们网站上的按钮.我知道这不是最好的选择,但对我来说这是最不令人反感的选择.
I am using Excel VBA code to click a button on our website. I know this isn't the best of things to be doing, but it is the least objectionable option available to me.
我可以使用这段代码,成功加载 imdb.com、google 等.但是当我加载我们的本地站点时,我失去了对 ie 对象的控制,我无法检查 readyState,我无法退出.
I can using this code, successfully load imdb.com, google, etc. But when I load our local site, I lose control of the ie object, I can't check readyState, I can't Quit.
这是我得到的错误.
运行时错误-2147023179 (800706b5)":
自动化错误
接口未知
Run-time error '-2147023179 (800706b5)':
Automation error
The interface is unknown
每隔一段时间我就会收到这条消息:
Every so often I instead get this message:
运行时错误'-2147417848 (80010108)':
自动化错误
调用的对象已与其客户端断开连接.
Run-time error '-2147417848 (80010108)':
Automation error
The object invoked has disconnected from its clients.
点击Debug表示ie.readyState
,我把它注释掉然后它指向ie.Quit
Clicking Debug indicates the ie.readyState
, I commented that out and then it points to ie.Quit
Sub dothestuff()
Dim ie As InternetExplorer
Set ie = New InternetExplorer
ie.Visible = True
ie.Navigate "http://www.google.com/"
anerror = webload(ie)
ie.Quit
Set ie = Nothing
End Sub
Function webload(ie)
Do Until ie.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
End Function
推荐答案
这里有一个快速简单的解决方案:
Here is a quick and easy solution for this issue:
代替:
set IE = createobject("internetexplorer.application")
使用:
Set IE = New InternetExplorerMedium
无需调整 IE 设置
这篇关于使用 Excel VBA 控制 Internet Explorer 本地 Intranet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!