Closing Excel Properly

  • Thread starter Thread starter Atley
  • Start date Start date
A

Atley

I have written an application that exports data from SQL to Excel.

It all works perfectly except that if you open the Task Manager after
running my application, there is an instance of Excel in the list for each
time the extract has been run.

I cannot seem to find anything on this, I have the application closing
properly as far as I can see, but it is staying in the process table and the
only way to get rid of it is to either reboot the machine or open the taks
manger and remove each process individually neither of which is acceptable.

here is my Excel closing code, what am I doing incorrectly here?

xlBook.Application.Visible = False
xlBook.SaveAs(MyFileName)
xlBook.Application.Quit()
xlBook = Nothing
xlApp = Nothing


any help is greatly appreciated...

Thanks
 
Hi,

xlBook.Application.Visible = False
xlBook.SaveAs(MyFileName)
xlBook.Application.Quit()
xlBook = Nothing
System.Runtime.Interopservices.marshal.releasecomobject(xlapp)
gc.collect


Ken
------------------
I have written an application that exports data from SQL to Excel.

It all works perfectly except that if you open the Task Manager after
running my application, there is an instance of Excel in the list for each
time the extract has been run.

I cannot seem to find anything on this, I have the application closing
properly as far as I can see, but it is staying in the process table and the
only way to get rid of it is to either reboot the machine or open the taks
manger and remove each process individually neither of which is acceptable.

here is my Excel closing code, what am I doing incorrectly here?

xlBook.Application.Visible = False
xlBook.SaveAs(MyFileName)
xlBook.Application.Quit()
xlBook = Nothing
xlApp = Nothing


any help is greatly appreciated...

Thanks
 
¤ I have written an application that exports data from SQL to Excel.
¤
¤ It all works perfectly except that if you open the Task Manager after
¤ running my application, there is an instance of Excel in the list for each
¤ time the extract has been run.
¤
¤ I cannot seem to find anything on this, I have the application closing
¤ properly as far as I can see, but it is staying in the process table and the
¤ only way to get rid of it is to either reboot the machine or open the taks
¤ manger and remove each process individually neither of which is acceptable.
¤
¤ here is my Excel closing code, what am I doing incorrectly here?
¤
¤ xlBook.Application.Visible = False
¤ xlBook.SaveAs(MyFileName)
¤ xlBook.Application.Quit()
¤ xlBook = Nothing
¤ xlApp = Nothing
¤

See if the following helps:

PRB: Office Application Does Not Quit After Automation from Visual Studio .NET Client
http://support.microsoft.com/default.aspx?scid=kb;EN-US;317109


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top