IE.navigate2在关闭保护模式时失败 [英] IE.navigate2 fails with protected mode off

查看:629
本文介绍了IE.navigate2在关闭保护模式时失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Excel VBA自动化IE8(Excel 2010,Windows 7)

I'm automating IE8 from Excel VBA (Excel 2010, Windows 7)

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

如果URL是IE所在区域中的网站保护模式已打开,一切正常。

If URL is a website in a zone where IE protected mode is on, everything is fine.

如果URL是IE保护模式关闭的区域中的网站,则脚本失败(IE变为自动可见,IE对象在VBA中丢失 - 自动化错误。)

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).

有没有办法在保护模式关闭的区域中启用navigate2?

Is there any way to enable navigate2 in zones with protected mode off?

推荐答案

您要做的是创建一个运行在中等完整性的IE实例,然后导航它。通常,您可以使用CoCreateInstance(CLSID_InternetExplorerMedium)来实现。目前,没有ProgID指向此CLSID,但是,您可以轻松创建一个:

What you want to do is create an instance of IE running at Medium Integrity, and navigate that. Typically, you'd do that by using CoCreateInstance(CLSID_InternetExplorerMedium). Currently, there's no ProgID that points at this CLSID, however, it you can easily create one:

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")

我在这里解释得更充分: http://blogs.msdn.com/b/ieinternals/archive/2011/08/03/internet-explorer-automation-protected-mode-lcie-default -integrity-level-medium.aspx

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

这篇关于IE.navigate2在关闭保护模式时失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆