Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need Command/Call to Kill Running Excel Instance
Message
From
20/04/2010 21:35:21
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
20/04/2010 09:20:53
Bill Drew
Independent Consultant
Chicago, Illinois, United States
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01461076
Message ID:
01461248
Views:
46
>I do a lot of Excel automation. So much that I have a standard stack of commands that I use over and over. oExcel = CreateObject("Excel Application") etc etc. Make an oBook object. Make an OSheet object. Get number of used rows. Iterate through the rows. Do something with the data. Close the Book. Quit Excel. and set the oExcel object to NULL.
>
>As I am writing the programs I invariably have bugs somewhere in the process. In those cases where the program never makes it to the final lines of setting the oExcel object to NULL, I have to go to the task manager to kill the instance before restarting.
>
>Is there an API call or command that I can use at the beginning of my programs to check for a running instance of Excel and to shut it down before starting a new one. Or (just thinking of another way) should I put the code into a try catch construct? The disadvantage of Try Catch is that interactive debugging is hobbled.

My trick is to have an object (custom) which will have this.oExcel=CreateObject("Excel Application"); in its .destroy() it releases Excel - .quit(0), set to null. If anything goes wrong, this object is released (usually after a cancel or from command window), and then its .destroy() fires. In 99% of the cases this removes the Excel process from memory. In rare cases when I have to kill Fox, I have to kill Excel too.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform