Solved

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

Posted on 2007-04-11
3
170 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…

758 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

20 Experts available now in Live!

Get 1:1 Help Now