Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

860 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