An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in XXX.exe.
I received this exception while coding and here are the steps to correct it. This code tries to add a sheet to the Excel workbook.
Error Details:
System.Runtime.InteropServices.COMException was unhandled
HResult=-2147352565
Message=Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
ErrorCode=-2147352565
Step 1: Open MS Excel on your local computer where the above code is running.
Setp 2: Go to File -> Options -> General tab
Step 3: Increase "Include this many sheets" value
I received this exception while coding and here are the steps to correct it. This code tries to add a sheet to the Excel workbook.
Error Details:
System.Runtime.InteropServices.COMException was unhandled
HResult=-2147352565
Message=Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
ErrorCode=-2147352565
Step 1: Open MS Excel on your local computer where the above code is running.
Setp 2: Go to File -> Options -> General tab
Step 3: Increase "Include this many sheets" value
This solution really helps. Thank you for share!
ReplyDeletethis solution has worked. thanks
ReplyDeleteI tried searching a lot of places, but to no avail. Finally found the solution here. Thanks for writing this answer.
ReplyDeleteStill getting the same error
ReplyDeleteThank you so much it works
ReplyDeleteWoah! I've been writing and running Factory Talk reports in Excel for the past year and this error was everything between a random nuisance and a show stopper.
ReplyDeleteThis finally fixed it! You're a legend! Thank you so so so much!