Some users with Microsoft Office 2013 began to complain about bug that happened during document exporting to Excel. Stack trace begins with line:
Microsoft.Office.Interop.Excel.ApplicationClass.Save(Object Filename) error Exception from HRESULT: 0x800A03EC. With ErrorCode: -2146827284. And nothing else. This error code, according to different articles in internet, can arise due to many reasons. Below is my version that can help somebody.
Code that leads to this error was:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Application xapp = null; Workbook workbook = null; ... xapp = new Application { DisplayAlerts = false, Visible = false }; workbook = xapp.Workbooks.Open(fileName); // Do some exporting things ... xapp.Save(); // this line produces error! workbook.Close(); ... |
After some investigantions and tries I’ve found that line
xapp.Save();
should be replaced with line:
workbook.Save();
and this helped to fix bug.