PDA

View Full Version : IE error message, only when not visible



eed
08-25-2009, 09:00 AM
Hello, all!

I'm running a procedure that loops through a series of records in a Word document. Part of it involves opening IE and navigating to a URL.

If IE runs Visible, the code runs perfect. If it runs NOT visible, at a random point (sometimes 14 records, sometime 90), it suddenly encounters an error on the "Navigate" command (something like "the remote application does not exist or is busy").

Here is an excerpt of the code:

strURLtest = "https://unx1.shsu.edu:9443/login?" _
& "url=http://atoz.ebsco.com/titles.asp?lang=en&id=8808&KW=" _
& strTitle & "&SF=Titles&ST=Exact"
Set appIE = New InternetExplorer 'WIN XP
'appIE.Visible = True
appIE.Navigate strURLtest
Do Until Not appIE.Busy And appIE.ReadyState = READYSTATE_COMPLETE
Loop
strSearchText = "Titles where title name exactly matches '" & strTitle & "': 0"


I can't understand why the error occurs only when IE runs not visible, and why it occurs at random, never on the same record. I'm likely doing something wrong--I'm still an amateur.

I've attached the Word doc with the complete procedure (ReplaceURL); please be aware though that the URLs in the code require login or approved IP, so testing might be difficult unless you change the URL. For further info: this is running on Windows XP, in Word 2007, using IE version 7.0.5730.13.

Many thanks in advance!!! :bouncy:

~eed

Tommy
08-25-2009, 09:16 AM
As a guess, have you tried to minimize the window?

I am thinking that it could be an add banner or something of that sort. Something that gets called to display something that works when it is visible and doesn't work when the window is not visible.

stanl
08-25-2009, 12:32 PM
Hard to tell from the code you posted. Are you running a single Instance of IE then looping to navigate, or opening /closing the IE object for each url in the Word Document. If you are positive it will always work if IE is not hidden then minimizing it might be an option. Unfortunately, I don't believe there is a minimize property in the IE Object; however there is a hwnd property, which you could use to obtain the window object and then set that to minimized. Just .02

P.S. I run scripts nightly that process numerous HTTPS sites and always run IE hidden; any problems are from the URL not my code, and I apply logic to retry.

eed
08-25-2009, 02:07 PM
Thanks for the ideas, Tommy and stanl!

stanl asked:
Are you running a single Instance of IE then looping to navigate, or opening /closing the IE object for each url in the Word Document.

Currently I am opening/closing the IE object each time because I had some issues at first with just trying to re-navigate the same object (though I think I may now have fixed what was causing those issues). Would it be preferable to just re-navigate?

~eed

stanl
08-26-2009, 03:40 AM
Would it be preferable to just re-navigate?

~eed

Always. If you find issues with navigating back to the same URL those could be related to caching... dunno. Might want to sort inputs from the Word document; occasionally navigate to about:blank; set URLs up as Trusted Sites; programmatically clear cache... there is just so much that can go wrong with IE and so many places to look for a fix:doh: