Properly disposing of an Excel.Application instance in C#.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JDeats

    #1

    Properly disposing of an Excel.Application instance in C#.

    So I have a reference to Microsoft Office 10.0 Object Library in my
    WinForms project (VS.NET 2005, 2.0 Framework)

    using Microsoft.Offic e.Core;
    using Excel;

    I have an instance of Excel.Applicati on (excelApp) that I need to
    properly dispose of. In my code I am using the following on
    Form_Unload:
    excelApp.Active Workbook.Close( true, Type.Missing, false);

    This doesn't seem to always do the trick... Is there a proper way to
    dispose of the Excel.Applicati on object and its associated objects?

  • Peter Duniho

    #2
    Re: Properly disposing of an Excel.Applicati on instance in C#.

    On Sun, 21 Sep 2008 17:33:33 -0700, JDeats <Jeremy.Deats@g mail.comwrote:
    [...]
    excelApp.Active Workbook.Close( true, Type.Missing, false);
    >
    This doesn't seem to always do the trick... Is there a proper way to
    dispose of the Excel.Applicati on object and its associated objects?
    It seems to me that the Excel.Applicati on.Quit() method would be
    appropriate.
    http://msdn.microsoft.com/en-us/library/bb223560.aspx

    That said, this probably isn't the best forum for Office interop
    questions. I don't know off-hand the exact forum that would be more
    appropriate, but surely there's one out there specific to that. If no
    useful answer is forthcoming here, you should probably try finding a more
    appropriate place for the question.

    Pete

    Comment

    Working...