Hi, So far you guys have been really awesome in helping me out with my MS problems. My program currently calls an Excel file to read from it. Before I call it, I will have a task kill function to kill any running excel tasks. I will call it again at the end to make sure any excel tasks are closed. However, during debugging, say if the program stops in the middle while running, with the Excel file open, it will show an error the next time I run it. This is because Excel has not been properly shut down and is still running in the background. I would then have to manually open Task Manager to end it before I start to prevent the error from occuring. The error goes like this "Microsoft VBScript runtime error:424 Object required 'xlApp'.
My question is, how do I perform error handling to ensure that if an error like this occurs, to immediately issue a Kill task command?[/img]
Error handling
Moderators: Dorian (MJT support), JRL
I'm not sure this is possible. Macro Scheduler processes script lines sequentially so I would think that when the script crashes any error handling would cease as well.
For convenience I would suggest creating another script that closes any process named "excel". Assign a hot key to that script and when your program crashes during debug all you need to do is press the hot key combination to close all instances of excel.
For convenience I would suggest creating another script that closes any process named "excel". Assign a hot key to that script and when your program crashes during debug all you need to do is press the hot key combination to close all instances of excel.
- Dorian (MJT support)
- Automation Wizard
- Posts: 1386
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
And/Or use a Window Event Trigger to watch out for the error popup?JRL wrote: For convenience I would suggest creating another script that closes any process named "excel". Assign a hot key to that script and when your program crashes during debug all you need to do is press the hot key combination to close all instances of excel.
Yes, we have a Custom Scripting Service. Message me or go here
-
- Pro Scripter
- Posts: 149
- Joined: Tue Mar 23, 2004 9:11 pm
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I guess you could use VBScript error trapping and return a value to the function and then check that value after VBEval and then if you want to terminate use the Exit command.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
What about error handling for corrupted files? Currently if a db query is running and it encounters a file that is corrupted and cannot be opened, it will hang. I would like for it to be able to log the file that is corrupted and skip that file and resume running the query. If anyone is willing to provide professional services to help me with this issue, please pm me.