0

hi,

i am trying to print report by ceating excel file and print. but getting below error when creating sheet2.

osheet = obook.Worksheets("Sheet2")

Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX)

worksheet1 works fine.

I have Excel 2013 installed on my system.

what could be the problem.

Thanks

2
Contributors
1
Reply
13
Views
3 Years
Discussion Span
Last Post by Minimalist
0

You are using the name the sheet and not it's index.
Example:
osheet = CType( obook.Worksheets.Sheets(2), Excel.Worksheet)
See if this works, otherwise you need to modify it.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.