VBScript で Excel
Excel のシート名を列挙する (ADO)
lesson007.vbs
実行結果
Dim cn' As ADODB.Connection
Set cn = CreateObject("ADODB.Connection")
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & WScript.Arguments(0) & ";Extended Properties=Excel 8.0;"
.CursorLocation = 3' adUseClient
.Open
End WithDim rs' As ADODB.Recordset
Set rs = cn.OpenSchema(20) 'adSchemaTables
Do Until rs.EOF
WScript.Echo rs.Fields("TABLE_NAME").Value
rs.MoveNext
Loop
rs.Closecn.Close
C:\>cscript c:\study\vbscript\chapter004\lesson007.vbs c:\study\Book1.xls //nolo
go
Sheet1$
Sheet2$
Sheet3$