Solved

Starting IE up - need to pause code until IE ready for navigate command

Posted on 2007-04-11
3
171 Views
Last Modified: 2010-04-30
Occasionally my code restarts Internet Explorer on purpose using:

objIE.Quit
Set objIE = Nothing
Set objIE = New InternetExplorer
objIE.Visible = True

But it seems that sometimes, the code sends a navigate command to IE a little too soon after restarting. IE isn't ready and errors out. I've inserted a 3 second pause, and that has seemed to help, but I still occasionally get the same error. How can I hold all further instruction until IE is up and ready to receive commands?
0
Comment
Question by:JohnDoeSr
3 Comments
 
LVL 4

Accepted Solution

by:
quiklearner earned 250 total points
ID: 18892910
unless you get some sort of event out of your objie object i am not sure you can..  if you do get a error to bubble back when it is not, trap it and retry the command until it works (probably a good idea to put a count on it though to stop eventually)
0
 
LVL 12

Expert Comment

by:jkaios
ID: 18893298
You can implement a loop to wait until the current page is loaded or the state is ready.

Do Until (objIE.ReadyState = 4)   'READYSTATE_COMPLETE
   DoEvents
Loop

-OR- use this:

Do While (objIE.Busy)
   DoEvents
Loop
0
 

Author Comment

by:JohnDoeSr
ID: 18894322
quiklearner: If I can't find any other solution then it sounds like I'm going to have to do this

jkaios: I've already got got that code in, right after the new the IE visible = true and it doesn't seem to help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Use Multiple Forms 4 49
Cannot enter table caption text in Word protected document 6 112
VB 6.0 printer how to align 6 58
VBA to copy paste columns form one file to other 20 86
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now