Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

how to add multiple sheets to excel file

$
0
0

i am adding multiple sheets to excel but it shows the exception System.Runtime.InteropServices.COMException: 'Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))' . the exception occurs at Position: xlWorkBook.Sheets("105")

    Dim xlApp As Excel.Application
    Dim xlWorkBook As Excel.Workbook
    Dim xlWorkSheet105 As Excel.Worksheet
    Dim xlWorkSheet120 As Excel.Worksheet
    Dim xlWorkSheet125 As Excel.Worksheet
    Dim xlWorkSheet600 As Excel.Worksheet
    Dim misValue As Object = System.Reflection.Missing.Value

    xlApp = New Excel.Application
    xlWorkBook = xlApp.Workbooks.Add()
    xlWorkSheet105 = xlWorkBook.Sheets("105")
    xlWorkSheet120 = xlWorkBook.Sheets("120")
    xlWorkSheet125 = xlWorkBook.Sheets("125")
    xlWorkSheet600 = xlWorkBook.Sheets("600")

Viewing all articles
Browse latest Browse all 88835

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>