Excel VBA控制IE本地Intranet [英] Excel VBA Controlling IE local intranet
问题描述
所以,我使用Excel VBA代码点击我们网站上的一个按钮,相信我,我知道这不是最好的事情,但它是目前我可用的最不令人反感的选择。
So, I am using Excel VBA code to click a button on our website, trust me, I know this isn't the best of things to be doing, but it is the least objectionable option available to me at this time.
所以,这个选择的方式,这里是我的问题,我可以使用这个代码,成功加载imdb.com,google等。但是当我加载我们的本地站点,我失去了对象的控制权,我无法检查readyState,我不能退出。这是我得到的错误。
运行时错误'-2147023179(800706b5)':
So, that choice out of the way, here is my problem, 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. Here is the error I get. Run-time error '-2147023179 (800706b5)':
自动化错误
界面未知
Automation error The interface is unknown
每隔一段时间我就会收到此消息:
运行时错误'-2147417848(80010108)':
Every so often I instead get this message: 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 also tried commenting 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控制IE本地Intranet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!