使用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
我经常收到以下消息:
运行时错误'-2147417848(80010108)':
自动化错误
调用的对象已与其客户端断开连接.
Run-time error '-2147417848 (80010108)':
Automation error
The object invoked has disconnected from its clients.
单击调试"表示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屋!