Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
735 views
in Technique[技术] by (71.8m points)

internet explorer - ie.busy not working well [VBA]

I am using :

While ie.busy
DoEvents
Wend

' Some Code

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.

Please suggest an infallible alternative to ie.busy

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:
'

You can try.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...