JohnDoeSr
asked on
Starting IE up - need to pause code until IE ready for navigate command
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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
jkaios: I've already got got that code in, right after the new the IE visible = true and it doesn't seem to help.
Do Until (objIE.ReadyState = 4) 'READYSTATE_COMPLETE
DoEvents
Loop
-OR- use this:
Do While (objIE.Busy)
DoEvents
Loop