code stops during run

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
sunole
Newbie
Posts: 14
Joined: Wed Aug 29, 2007 6:28 pm

code stops during run

Post by sunole » Thu Jun 16, 2011 6:21 am

I have this sample of code below which is called from VBEval> , it runs fine all day, but sometimes the macro stops with error window (title Macro Scheduler) and inside the window:
:-2147467259

Line 13, Column 2

( OK ) (Abort)

this breaks automation, line 13 is the Set IE line.
I already have in the script this option:
let>IGNOREERRORS=1

so it is a bummer to still get this error and break the automation.

one additional symptom, by the end of the day there may be multiple iexplorer.exe process running in the background and I have to clear them manually, which is not as big problem of the script stop from running, please help how not to get the error window and script stopping, thanks in advance.

=====
Function HTTPGet(URL)
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 0
IE.navigate URL
do while IE.Busy
loop
On Error Resume Next
HTTPGet = IE.document.documentelement.outerhtml
IE.quit
Set IE = Nothing
End Function

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jun 16, 2011 8:18 am

This is an IE/COM/VBScript issue. It sounds like IE is failing to close properly. And then my _guess_ is that once you have too many stray IE processes the CreateObject fails because it cannot create any more instances.

It may be worth introducing a delay between the HTTPGet and the IE.quit. Maybe you need a loop to wait while busy there (copy the previous loop down).

Another thing you can do is just to kill the IE process after your VBEval:

VBEval>HTTPGet("...")...
Wait>0.5
KillProcess>iexplore.exe

This is a bit brute force but in lieue of discovering why IE is failing to respond to the IE.quit and close properly it will at least ensure that the process is no longer and should hopefully therefore prevent later problems with CreateObject ...

If you are calling this code in a loop consider doing the CreateObject only the first time, then not closing IE and instead leave IE open to do later naviations and "HTTPGets" against the same instance, and only doing IE.quit at the end of the macro.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

sunole
Newbie
Posts: 14
Joined: Wed Aug 29, 2007 6:28 pm

easy way to abort or OK

Post by sunole » Tue Jun 28, 2011 5:37 am

is there an easy way to just click the abort or the OK, that would be much easier,

I tried to make a script that waits for the "Macro Scheduler" window to click the abort, but it get confused with which window to look at, this main script or this window that could pop up, help, thanks in advance

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts