ie.busy运作不佳[VBA] [英] ie.busy not working well [VBA]

查看:736
本文介绍了ie.busy运作不佳[VBA]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用:

While ie.busy
DoEvents
Wend

' Some Code

在我的代码中添加暂停,同时Internet Explorer刷新。但这似乎并没有奏效。 '某些代码部分正在逐渐执行并抛出错误。

To add a pause in my code, while internet explorer refreshes. But this doesnt seem to be working well. The 'Some code part is getting executed pre-maturely and throwing an error.

我也尝试过使用其他方法。例如

I have tried using other methods as well. for e.g.

Errorhandler:

While ie.busy
DoEvents
Wend

On Error Goto Errorhandler
'Some Code

但即便如此这不起作用,有时代码会在成熟之前被执行。

But even this isnt working and sometimes the code is esecuted pre maturely.

请建议使用ie.busy的绝对替代方案

Please suggest an infallible alternative to ie.busy

推荐答案

在我们的代码中,ie.Busy(InternetExplorer.Application Object)不是很可靠。以下是我们使用和工作的内容:

In our code, ie.Busy (InternetExplorer.Application Object) is not very credible. Here is what we use and works:

Enum READYSTATE
    READYSTATE_UNINITIALIZED = 0
    READYSTATE_LOADING = 1
    READYSTATE_LOADED = 2
    READYSTATE_INTERACTIVE = 3
    READYSTATE_COMPLETE = 4
End Enum

Dim strUrl
Dim ie As Object

Set ie = CreateObject("InternetExplorer.Application")
'....
' do navigation...
'
strUrl = "http://www.example.com/"
ie.Navigate strUrl

'
' waiting for the ie complete loading:
'
Do While (ie.Busy Or ie.READYSTATE <> READYSTATE.READYSTATE_COMPLETE)
  DoEvents
Loop

'
' here below you do stuffs on the new loaded URL:
'

你可以试试。

这篇关于ie.busy运作不佳[VBA]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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