Error When Running VB script.

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Error When Running VB script.

Post by Jmac2501 » Tue Mar 20, 2007 4:33 am

I have been Running this VB script to kill my Exell process for over a week now and it just stoped working tonight. This is the error i get:

:-2147217404


Line 12, Column 21

OK Abort



This error pops up at the end of this section on the VB script:

ifwindowopen>Microsoft Excel*
VBSTART
Sub killProcess(pgm)
set wmi = getobject("winmgmts:")
sQuery = "select * from win32_process " & "where name='" & pgm & "'"
set processes = wmi.execquery(sQuery)
for each process in processes
process.terminate
next
End Sub

VBEND
VBRun>KillProcess,excel.exe
else
endif

User avatar
Captive
Macro Veteran
Posts: 213
Joined: Sun Oct 20, 2002 8:37 pm
Location: Colorado, USA

Post by Captive » Tue Mar 20, 2007 6:37 am

Works fine here. Please provide this info;
1) What version of Macro Scheduler.
2) In your editor, what shows as line 12?

Also, please check the ends of each line for any trailing spaces.

Personally, I put the IfWindowOpen after the VBEND, and exclude the "else" unless I have stuff to excecute, like this;

Code: Select all

IfWindowopen>Microsoft Excel*
VBRun>KillProcess,excel.exe
Endif

Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Post by Jmac2501 » Tue Mar 20, 2007 9:37 am

Its working again now. Couldn't get it to work for the life of me today. So i am lost on this one. Thanks any way.

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