Share via

Microsoft Excel COMException

Anonymous
2010-10-07T10:27:05+00:00

Hi All,

we are working on windows application(Windows XP Professional Version 2002 Service Pack 3, Dot net framework 2.0, C#, Microsoft office 2003/2007). We are generating excel report using Microsoft Office Excel component[Microsoft Excel 11.0 Object Library for Office 2003 and Microsoft Excel 12.0 Object Library for Office 2007].

Consider we generate a Excel report using our C# application and save it on desktop (say Report1.xls) and again go for generating another excel report using the same application. When this process is still running, simultaneously open already saved report (Report1.xls ) and try to edit it. On editing the report  we are getting the following COM exception.

         “System.Runtime.InteropServices.COMException (0x800AC472): Exception from HRESULT: 0x800AC472”.

After completion of generating excel report, still the excel.exe process running in the task manager.

We have tried following solution to resolve the issue:

Ø To release the object we have used

       ExcelApplication.Quit()

         System.Runtime.InteropServices.Marshal.ReleaseComObject (ExcelSheet);   System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelBook);

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

   ExcelSheet = null;

   ExcelBook = null;

   ExcelApplication = null;

   System.GC.Collect();

Please help us resolve the COMException.

Thanks in advance..

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2010-10-08T17:05:42+00:00

Try putting

System.GC.WaitForPendingFinalizers()

after your System.GC.Collect() line of code.


Cordially, Chip Pearson Microsoft MVP, Excel Pearson Software Consulting, LLC www.cpearson.com

Was this answer helpful?

0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2010-10-08T09:48:00+00:00

    Check thislink which describes about the same error message you get.


    Sachin Shetty

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2010-10-07T12:20:30+00:00

    Maybe Excel still has a file open and when you do Quit it is asking if you want to close it?

    Maybe you need to do the equivalent of VBA

      ActiveWorkbook.Close saveChanges:=False

    ?


    Bill Manville. Excel MVP, Oxford, England. www.manville.org.uk

    Was this answer helpful?

    0 comments No comments