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

Occasionally my code restarts Internet Explorer on purpose using:

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?
Who is Participating?
quiklearnerConnect With a Mentor Commented:
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)
jkaiosIT DirectorCommented:
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

-OR- use this:

Do While (objIE.Busy)
JohnDoeSrAuthor Commented:
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.
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.

All Courses

From novice to tech pro — start learning today.