I am getting HRESULT: 0x800A03EC on Worksheet.range method. Number of rows are more than 70K. Office 2007.
Code:
Microsoft.Office.Interop.Excel.Range neededRange
= currentWS.Range[cell.Cells[1, 1], cell.Cells[nRowCount, nColumnCount]];
Here my rowcount is more than 65530 . Breaks on this function. I have observed that it breaks only when row count goes more than 65530.
This type of error also occurs when you try to open your excel sheet and if it is prompting any error message. simply you can say when your excel file is corrupted.
I got this exception because I typed:
See a mistake? Hint: Excel is accepting indexing from 1, but not from 0 as C# does.
I got this error because I tried to rename a sheet with too many characters
I resolved this issue by using the code below. Please do not use other parameters in these functions.
RESOLVED
Simply, the excel file is corrupt. Best solution is change/repair the file.(make a copy of the existing file and rename it)
I agree with Hugh W post "I conclude that the same error code is used to indicate multiple unrelated problems"
Other posts have not mentioned that this error occurs frequently if the worksheet is locked. While I haven't tested every scenario, it seems that anything that you can not do in excel when a worksheet is locked with throw this error if you attempt to do it via VSTO/Com while the sheet is locked. E.G. Changing any style artifact (font, font size, colour, underline), changing the Excel Validation, changing the column widths, row heights, formulas