操作対象のExcelファイルのシート数を取得します。
' Excelアプリケーション Private xlApp As Application = Nothing ' ワークブック Private xlBooks As Workbooks = Nothing Private xlBook As Workbook = Nothing ' シート Private xlSheets As Sheets = Nothing xlApp = New Application xlBooks = xlApp.Workbooks xlBook = xlBooks.Open('対象ファイルまでの完全パス') xlSheets = xlBook.Worksheets ' 対象ファイルのシート数取得 MessageBox.Show(xlSheets.Count)