Problem Closing Excel

M

m.ahrens

Hi All

I have problems Closing excel...
Excel 2003 / Visual Studio 2003 / C#

The Code I use:

oExcel.WorkbookBeforeSave -= EventDel_BeforeBookSave;
oExcel.WorkbookDeactivate -= EventDel_Deactivate;

PIDHandler.NAR(wSheet);
wBook.Close(false, Type.Missing, Type.Missing);
PIDHandler.NAR(wBook);
PIDHandler.NAR(wBooks);
oExcel.Quit();
PIDHandler.NAR(oExcel);
GC.Collect();
GC.WaitForPendingFinalizers();

static public void NAR(object o)
{
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(o);
}
catch
{
}
finally
{
o = null;
}
}

After Compleating the code above, Excel produces a total crash: "Microsoft
Office Excel has encountered a problem and needs to close. We are sorry for
the inconvenience." You know, this error, where you can send a "Error Report"
to microsoft. What might i be doing wrong?

thanks for your help

m.ahrens
 
M

m.ahrens

Found the solution...tried to close the objects in an excel event...how
should an object destroy it self from the inside...think i have to go to
school again;-)

have a nice day!
 

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