[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-11-12
4
Medium Priority
?
2,782 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:Flash5
4 Comments
 
LVL 6

Accepted Solution

by:
Marv-in earned 200 total points
ID: 12564404
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
 
LVL 11

Assisted Solution

by:dbrckovi
dbrckovi earned 100 total points
ID: 12564535

 - 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
 
LVL 32

Expert Comment

by:Erick37
ID: 12569184
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
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 12571799
>>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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question