set timeout value on CreateObject("InternetExplorer.Application")

sample code:

Set myIE = CreateObject("InternetExplorer.Application")
   
myIE.navigate "http://demo.com"

Do Until myIE.Busy = False
    DoEvents
Loop

How can i set the timeout value for the http request?

thanks
Flash5Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Marv-inCommented:
the easy way is to use the timer control
dim bTimeOut as boolean

bTimeOut = False
timer1.enabled=true
Do Until myIE.Busy = False or bTimeOut
    DoEvents
Loop

Private Sub Timer1_Timer()
timer1.enabled=false
bTimeOut = true
end sub

the hard way would be to use the timer api functions
http://visualbasic.ittoolbox.com/documents/document.asp?i=1569
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dbrckoviCommented:

 - create a timer control and a command button
 - paste this code:
'---------------------------------------------------
Dim myIE As Object
Dim ElapsedTime As Integer

Private Sub Form_Load()
    Timer1.Enabled = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
    myIE.quit
    Set myIE = Nothing
End Sub


Private Sub Command1_Click()
    Set myIE = CreateObject("InternetExplorer.Application")
   
    myIE.Visible = True
    myIE.navigate "http://www.google.com"

    ElapsedTime = 0
    Timer1.Interval = 1000
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    If myIE.busy = False Then
        MsgBox "Done!"
    Else
        ElapsedTime = ElapsedTime + 1
        If ElapsedTime = 10 Then
            myIE.stop
            MsgBox "Time-out!"
            Timer1.Enabled = False
        End If
    End If
End Sub
'----------------------------------------------
0
Erick37Commented:
You can use DateDiff to compare 2 times, in this case we can see when the request has exceeded our time limit.

Dim lSeconds As Long
Dim dtStart As Date

'Set a 3 second timeout
lSeconds = 3
'Get the time before navigating
dtStart = Now
'navigate
myIE.Navigate2 "http://weather.com"

'Check the time against the start time
Do While (myIE.ReadyState <> READYSTATE_COMPLETE)
    DoEvents
    If (DateDiff("s", dtStart, Now) > lSeconds) Then
        myIE.Stop
        Debug.Print "Time Out"
        Exit Do
    End If
Loop
0
zzzzzoocCommented:
>>How can i set the timeout value for the http request?
IE has it's own time-out so to avoid conflicts with it, you may want to change IE's time-out instead.

http://support.microsoft.com/default.aspx?scid=kb;en-us;181050

If you don't think your custom time-out will exceed IE's, the above suggestions would be better.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.