Excel doesn't close

C

Christof Nordiek

Hi,

how can I close the excel-process when automating excel?
After calling Quit() on the Application-object the process remains running
(as i see in Taskmanager).
In Word Quit stops the process.

PS i'm programming in .NET and use the PIA's for Office 2003

Thanks
 
D

Dave Hart

I don't use .NET, but in C++ I have to release all interfaces
before Excel will go away.
It's likely that you have another interface open to Excel.

Dave Hart
 
C

Christof Nordiek

Thanks Dave,

now my question is: How to 'release all interfaces' from .NET point of view.
After calling Quit() the method closes and so the variable looses scope,
thats all i can do.
Also setting the variable to null and calling the garbagecollection
(GC.Collect()) doesn't close the Process.
That's all i can do.
Automating Word Quit closes the Process.

Exists the difference between Word and Excel also in C++?

Thanks for comments.

Christof
 
D

Dave Hart

Christof

Again, I've no idea what to do in .NET,
but in C++ I have member variables for Excel objects:
_ApplicationPtr m_pApp;
_WorkbookPtr m_pBook;
_WorksheetPtr m_pSheet;
WorkbooksPtr m_pBooks;
WorksheetsPtr m_pSheets;

In my class destructor, I release them like this:
if (m_pApp)
m_pApp.Release();
if (m_pBooks)
m_pBooks.Release();
if (m_pSheets)
m_pSheets.Release();
if (m_pBook)
m_pBook.Release();
if (m_pSheet)
m_pSheet.Release();

Dave
 
C

Christof Nordiek

Christof Nordiek said:
Thanks Dave,

now my question is: How to 'release all interfaces' from .NET point of
view.

Figuered it out:

System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);

where obj is the COM-Object to release.
This has to be called on any Excel-Object that is referenced in the
program..
 

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