Excel Interop problem

D

Dries

Hello,

I am using Excel Interop to export data from a dataset to an excel-file.
Everything works fine except closing the excel-file.

I have an Application-object and a Workbook-object. I call the Close
method on the Workbook en the Quit on the Application.

My program works fine but after my program is closed, I can still see
Excel running as a process on my pc, this gives troubles when shutting
down the pc.

Anyone who has an idea?

Thanks,
Dries
 
L

Lucky

hi Dries,

well i think in ur case u can use
System.Runtime.InteropServices.Marshal.ReleaseComObject()

this method to release the COM object whenever you close the
application which should Dispose the EXCEL application object.

call it in your form closing event when u finish working with EXCEL
application object and run this loop in the event. pass your EXCEL
Application object to the method.

While System.Runtime.InteropServices.Marshal.ReleaseComObject("Excel
Application Object") = 0
End While
 
L

Lucky

hi Dries,

well i think in ur case u can use
System.Runtime.InteropServices.Marshal.ReleaseComObject()

this method to release the COM object whenever you close the
application which should Dispose the EXCEL application object.

call it in your form closing event when u finish working with EXCEL
application object and run this loop in the event. pass your EXCEL
Application object to the method.

While System.Runtime.InteropServices.Marshal.ReleaseComObject("Excel
Application Object") = 0
End While
 
D

Dries

Lucky said:
hi Dries,

well i think in ur case u can use
System.Runtime.InteropServices.Marshal.ReleaseComObject()

this method to release the COM object whenever you close the
application which should Dispose the EXCEL application object.

call it in your form closing event when u finish working with EXCEL
application object and run this loop in the event. pass your EXCEL
Application object to the method.

While System.Runtime.InteropServices.Marshal.ReleaseComObject("Excel
Application Object") = 0
End While
thanks, it works
 

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

Top