简体   繁体   English

IE.navigate2在关闭保护模式时失败

[英]IE.navigate2 fails with protected mode off

I'm automating IE8 from Excel VBA (Excel 2010, Windows 7) 我正在从Excel VBA自动化IE8(Excel 2010,Windows 7)

Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate2 URL

If URL is a website in a zone where IE protected mode is on, everything is fine. 如果URL是IE保护模式所在区域中的网站,则一切正常。

If URL is a website in a zone where IE protected mode is off, the script fails (IE becomes automatically visible, IE object is lost in VBA - automation error). 如果URL是IE保护模式关闭的区域中的网站,则脚本将失败(IE将自动显示,IE对象在VBA中丢失 - 自动化错误)。

Is there any way to enable navigate2 in zones with protected mode off? 有没有办法在保护模式关闭的区域中启用navigate2?

What you want to do is create an instance of IE running at Medium Integrity, and navigate that. 您要做的是创建一个以中等完整性运行的IE实例,然后导航它。 Typically, you'd do that by using CoCreateInstance(CLSID_InternetExplorerMedium). 通常,您可以使用CoCreateInstance(CLSID_InternetExplorerMedium)来实现。 Currently, there's no ProgID that points at this CLSID, however, it you can easily create one: 目前,没有ProgID指向此CLSID,但是,您可以轻松创建一个:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\InternetExplorer.ApplicationMedium]

[HKEY_CLASSES_ROOT\InternetExplorer.ApplicationMedium\CLSID]
@="{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}"

You can then invoke this object thusly: 然后,您可以这样调用此对象:

CreateObject("InternetExplorer.ApplicationMedium")

I explain a bit more fully over here: http://blogs.msdn.com/b/ieinternals/archive/2011/08/03/internet-explorer-automation-protected-mode-lcie-default-integrity-level-medium.aspx 我在这里解释得更充分: http//blogs.msdn.com/b/ieinternals/archive/2011/08/03/internet-explorer-automation-protected-mode-lcie-default-integrity-level-medium的.aspx

通过CLSID获取InternetExplorer.ApplicationMedium:

Set IE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM