LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mo Mo is offline
external usenet poster
 
Posts: 69
Default Excel Won't close in .NET 3.5 using C#

I have tryed all the various versions of closing an excel object, but it
still remains in the Task Manager.
CODE SAMPLE ONE: =====================================
xlBook.SaveAs(getFile, Excel.XlFileFormat.xlWorkbookNormal, null, null,
true, false, Excel.XlSaveAsAccessMode.xlShared, false, false, null, null,
null);

xlBook.Close(null, null, null);
xlApp.Workbooks.Close();
xlApp.Quit();

System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlApp);
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlSheet);
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlBook);

xlSheet = null;
xlBook = null;
xlApp = null;
GC.Collect(); // force final cleanup!

CODE SAMPLE TWO: =====================================
xlBook.Close(true, GLName, null);
xlApp.Workbooks.Close();

GC.Collect(); // force final cleanup!
GC.WaitForPendingFinalizers();

System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlRng);
xlRng = null;
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlSheet);
xlSheet = null;
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlBook);
xlBook = null;
xlApp.Quit();

System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlApp);
xlApp = null;

==================================================

I really hoped that this was fixed by now, I 've been fighting with this
since VB6... Any suggestion?
--
MJB
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
why do all excel worksheets/workbooks close when I close one? Penny Excel Discussion (Misc queries) 1 November 29th 06 03:49 AM
Can I stop the close method in an auto close macro Paul Excel Programming 2 November 17th 06 02:48 PM
Not close thead when I close excel wakeup[_3_] Excel Programming 0 December 5th 05 08:57 AM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
excel - Windows close button (x) should only close active workboo. CoffeeAdict Setting up and Configuration of Excel 3 February 8th 05 04:30 AM


All times are GMT +1. The time now is 11:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"