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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.