VBA InternetExplorer.Application对象挂起 [英] VBA InternetExplorer.Application Object Hang

查看:332
本文介绍了VBA InternetExplorer.Application对象挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有VBA的旧Excel文档,它可以在Windows 7上与IE 11一起使用,但是在Windows 10上的IE 11上它不起作用。 IE 11启动到所请求的URL,但就是这样。无论何时我尝试访问事件,方法或属性,它都会停止。没有错误代码,没有崩溃,只是停止。

I'm using an old Excel document with VBA that works fine with IE 11 on Windows 7, however on IE 11 on Windows 10 it does not work. IE 11 launches to the URL requested but that's it. Anytime I try to access a event, method, or property, it stops. No error code, no crash, just stops.

我已经确认我对 Microsoft Internet Controls Microsoft HTML对象的引用包含库(它们不是,但它们现在是)。

I've confirmed that my references to Microsoft Internet Controls and Microsoft HTML Object Library are included (they weren't but they are now).

Dim ie As Object

If ie Is Nothing Then
   Set ie = CreateObject("InternetExplorer.Application")
   ie.Visible = True
End If

url = "www.myurl.com"

ie.Navigate url

While ie.ReadyState <> 4 Or ie.Busy: DoEvents: Wend

检查代码从未执行,我之前放置了MsgBox代码然后进行测试。在循环之前只有MsgBox工作,除非我尝试使用 MsgBox ie.Document.Title ,但我可以做 MsgBox ie.ReadyState MsgBox正在加载网页就好了。

Code bellow the check never executes, I placed MsgBox code before and after for testing. Only MsgBox before the loop works, unless I try to use MsgBox ie.Document.Title, but I can do MsgBox ie.ReadyState or MsgBox "Loading webpage" just fine.

再次代码完全没问题在Windows上没问题7使用IE 11,但在使用IE 11的Windows 10上不起作用。在多台具有相同结果的W7和W10机器上测试。

Again the code works perfectly fine no problem on Windows 7 with IE 11, but does not work on Windows 10 with IE 11. Tested on multiple W7 and W10 machines with identical results.

推荐答案

<在尝试了许多不同的选项之后,我终于能够让它发挥作用了。根据OmegaStripes的建议,我开始搞乱兼容模式。像许多事情一样,最简单的解决方案最终成为正确的解决方案。将我的Intranet站点添加到兼容性视图设置后,它可以完美地对VBA进行零代码更改。

After trying many different options I was finally able to get it to work. Per OmegaStripes recommendation, I began messing with the compatibility modes. Like many things, the simplest solution ended up being the correct one. After adding my intranet site to the compatibility view settings it worked perfect with zero code changes to the VBA.


  1. 启动 IE 11

  2. 点击工具

  3. 点击兼容性视图设置

  4. 在文本区域输入您的网址,然后点击添加

  5. 选中以兼容模式显示Intranet网站

  6. 点击关闭

  1. Launch IE 11
  2. Click Tools
  3. Click Compatibility View Settings
  4. Type your URL into the text area and click Add
  5. Check Display Intranet sites in Compatibility Mode
  6. Click Close

执行此操作后,我退出IE 11,重启我的Excel电子表格与之前无法运行的VBA。执行VBA代码,它就像在Windows 7上使用IE 11一样。

After doing this I exited IE 11, restarted my Excel spread sheet with the VBA that was previously not functioning. Executed the VBA code, and it worked just as it did on Windows 7 with IE 11.

希望这可以帮助其他人并为他们节省很多麻烦。

Hope this helps some one else and saves them a lot of headache.

特别感谢 OmegaStripes 与我一起坚持并帮助我看到实际问题,而不是过度思考。

Special thanks to OmegaStripes for sticking through this with me and helping me see the actual problem rather than over thinking it.

这篇关于VBA InternetExplorer.Application对象挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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