Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Random Errors using CreateObject to Start IE

75 views
Skip to first unread message

Rick Kasten

unread,
Sep 30, 2003, 9:32:50 AM9/30/03
to
Here is some code from a script I wrote:

Set IE = WScript.CreateObject("InternetExplorer.Application")
IE.Left = 50
IE.Top = 50
IE.Width = 690
IE.Height = 530
IE.Menubar = FALSE
IE.Resizable = TRUE
IE.Statusbar = FALSE
IE.Toolbar = FALSE
IE.Navigate("about:blank")
IE.Visible = TRUE
Set oDialog = IE.Document

Randomly, the script generates an error at this point

462: The remote server machine does not exist or is unavailable

I am creating the InternetExplorer.Application object on my own
system, so there is no remote system. The problem doesn't occur too
often, but once the problem starts, I can't do anything to fix it
other than rebooting or just leaving the system alone for literally a
few hours. Then the problem just goes away. Any ideas?

Tom Lavedas

unread,
Sep 30, 2003, 9:56:32 AM9/30/03
to
The error occurs because IE has failed to completely
load. You need a loop that waits until IE and the
document are completly loaded. That is ...


Set IE = WScript.CreateObject


("InternetExplorer.Application")
IE.Left = 50
IE.Top = 50
IE.Width = 690
IE.Height = 530
IE.Menubar = FALSE
IE.Resizable = TRUE
IE.Statusbar = FALSE
IE.Toolbar = FALSE
IE.Navigate("about:blank")

' Wait until loaded. Requires WSH version 5.1+
Do Until oIE.ReadyState = 4 : Wscript.Sleep 100 : Loop
'


IE.Visible = TRUE
Set oDialog = IE.Document

Tom Lavedas
===========

>.
>

Rick Kasten

unread,
Sep 30, 2003, 4:43:12 PM9/30/03
to
Your code exactly as you sent it failed to work. In fact, I had the
same exact error as before. I moved your Do Loop up to the top,
immediately following my Set IE line, and it still failed. In fact, a
couple of times the oIE.ReadyState itself failed with the same error.
I did some more research and found this code:

Do
Loop While oIE.Busy

which did not always work either. Here is the code that works now:

Set oIE = WScript.CreateObject("InternetExplorer.Application")
Do
Loop While oIE.Busy
oIE.Left = 50
Do
Loop While oIE.Busy
oIE.Top = 50
oIE.Width = 690
Do
Loop While oIE.Busy
oIE.Height = 530
oIE.Menubar = FALSE
Do
Loop While oIE.Busy
oIE.Resizable = TRUE
oIE.Statusbar = FALSE
Do
Loop While oIE.Busy
oIE.Toolbar = FALSE
oIE.Navigate("about:blank")


Do Until oIE.ReadyState = 4 : Wscript.Sleep 100 : Loop

oIE.Visible = TRUE

As you can see, I am pausing every other line which seems pretty
ridiculous. However, it is working for now. I would appreciate any
further ideas, as I think a solution closer to yours is better than
what I am doing now....

Rick


"Tom Lavedas" <tlav...@hotmail.com> wrote in message news:<199f801c3875a$a79322b0$a601...@phx.gbl>...

Tom Lavedas

unread,
Sep 30, 2003, 5:56:07 PM9/30/03
to
I don't see why the original formulation didn't work. I
have any number of scripts with that EXACT line of code,
and they work flawlessly - every time.

Conceptually, the loop you suggest is identical to what I
provided, except that Michael Harris has suggested that
the Busy property sometimes provides unreliable results.

Sorry, I don't see the problem (or a potential solution).
I really don't think you need all of those other loops. I
certainly never have.

What OS and version of IE. Maybe someone else can shead
some light with that info.

Tom Lavedas
===========

>.
>

Rick Kasten

unread,
Oct 1, 2003, 2:13:51 PM10/1/03
to
I'm testing a theory. I had "On Error Goto 0" in my script. I think
that the object will generate errors if any property is set when the
IE object is not ready, but that doesn't mean that the object will not
"catch up." I removed the "On Error Goto 0" line, and I am now
running your code exactly as you have it. I think that the pause has
to occur to let the object catch up before setting a new object to
IE.Document. That makes sense to me, because before when I was not
pausing and had "On Error Resume Next", my script would just run
without the IE window popping up.

I think your code will work for me now. I'll let you know if I
continue to have problems.

Rick


"Tom Lavedas" <tlav...@hotmail.com> wrote in message news:<0a3201c3879d$a717dcc0$a301...@phx.gbl>...

0 new messages