SOLVED - Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX) in C#

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

Comments

  1. This solution really helps. Thank you for share!

    ReplyDelete
  2. this solution has worked. thanks

    ReplyDelete
  3. I tried searching a lot of places, but to no avail. Finally found the solution here. Thanks for writing this answer.

    ReplyDelete
  4. Woah! 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.

    This finally fixed it! You're a legend! Thank you so so so much!

    ReplyDelete

Post a Comment