シート名を指定してワークシートオブジェクトを取得する

 

シート名を指定してワークシートオブジェクトを取得するサンプル

 

            Dim xlWorkBook As Excel.Workbook

            Dim xlSheets As Excel.Sheets

            Dim xlSheet As Excel.Worksheet

            Dim SheetName  As String

 

            'エクセルを開く

            xlWorkBook = xlApp.Workbooks.Open(”hoge.xls”)

            'シートを開く

            xlSheets = xlWorkBook.Worksheets

            For i As Integer = 1 To xlSheets.Count

                   'シート名取得

                    SheetName = xlSheets.Item(i).Name.ToString

                   '指定したシート名のワークシート取得

                    If  SheetName = "fugfuga" Then

                    xlSheet = xlWorkBook.Worksheets(i)

                    Exit For

                End If

            Next

 

http://www.vbnetdb.net/xlscreator/xlscr07_sheet_sheetcount.php

http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1416790264