Excelの名前付きセルの位置および、列数・行数を取得する方法を記載します。

名前付きセルの位置および行数・列数を取得する

Dim xlApp As Excel.Application = New Excel.Application()
Dim xlBook As Excel.Workbook = xlApp.Workbooks.Open("C:\work\myBook.xls")
Dim xlSheet As Excel.Worksheet = xlBook.Worksheets("Sheet1")

Dim xlRange As Excel.Range = xlSheet.Range("ALL")

'列の位置
Dim x As Integer = xlRange.Column
'行の位置
Dim y As Integer = xlRange.Row

'列の数
Dim cols As Integer = xlRange.Columns.Count
'行の数
Dim rows As Integer = xlRange.Rows.Count

xlSheet.Activate()
xlApp.Visible = True

System.Threading.Thread.Sleep(3000)
xlApp.Quit()

System.Runtime.InteropServices.Marshal.ReleaseComObject(xlRange)
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet)
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBook)
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)