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??
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.