I am exporting data to Excel from within my C# application, using the Microsoft.Office.Interop.Excel
library.
Calling sheet.Cells[currentRow, 1])
with an invalid currentRow
value, results in a System.Runtime.InteropServices.COMException
with the message:
"Exception from HRESULT: 0x800A03EC"
and the ErrorCode
-2146827284
However, I've received the exact same errorcode for ordering Excel to save to a write protected file.
Is there a way for me to distinguish between the COMExceptions received from Excel, so I can handle them accordingly? I would rather not leave my users with "Something went wrong while working with Excel, sorry, sucker."