我有一些代码可以通过VBA中的Internet Explorer自动化从多个网站检索数据 . 我的代码在IE8中没有问题,但是在IE11中,在调用Internet Explorer对象的Navigate方法之后,Document和LocationURL没有更新;他们仍然参考以前显示的网站 . 这是重现问题的一些代码:

Sub Test()

Debug.Print "start"

Dim ie

Set ie = CreateObject("InternetExplorer.Application")

ie.Visible = True

ie.Navigate "http://en.wikipedia.org/wiki/Visual_Basic"

wait ie

Debug.Print "Current URL: " & ie.LocationURL

ie.Navigate "http://en.wikipedia.org/wiki/Microsoft_Office"

wait ie

Debug.Print "Current URL: " & ie.LocationURL

Set ie = Nothing

End Sub

Sub Wait(ie As Variant)

Do While ie.Busy

Application.wait DateAdd("s", 1, Now)

Loop

End Sub

当在具有IE8的机器上运行上述Test子时,它会打印两个不同的URL,这是预期的行为 . 但是,当我在使用IE11的计算机上运行相同的代码时,它会打印第一个URL两次 . 知道什么可能是错的吗?

Update :我找不到解决方案,所以我去为每个URL打开一个新的IE窗口 .

Logo

一站式 AI 云服务平台

更多推荐