Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
740 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...