Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

End Process for Excel.Exe

Status
Not open for further replies.

REDYPS

Programmer
Jun 12, 2003
12
US
Another Excel problem I've noticed is that Excel processing doesn't always end when you close the application. How can I make sure the process ends in background when the form is closed??

thanks.
 
You need to make sure you close all your objects that Excel creates on your behalf in the reverse order in which they were created. For example, if you create a new workbook object, Excel will create some worksheet objects for you. You need to set them to Nothing before setting the enclosing workbook to nothing.

Also, don't forget that VB.NET is a garbage-collected language. It's possible for an instance of Excel to hang around until it gets collected.

If you're running Excel on a server (which is not recommended, BTW), you can create a singleton object to control access to Excel. Whenever a class wants to use Excel, it "checks-out" the copy from the singleton, uses it, then "checks-in" when it's done with it, allowing other classes to use it afterwards (Excel is not multi-thread aware).

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top