' ExcelMarge.vbs
' Usage : CScript ExcelMarge.vbs
Const DIR = "E:\home\edu\excel\tmp\data" ' 対象データ
Const XLS = "E:\home\edu\excel\tmp\marge.xls" ' マージ先のファイル
Marge
Sub Marge
Dim cn
Dim rs
Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & XLS & ";Extended Properties=Excel 8.0"
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
Dim folder
Set folder = fs.GetFolder( DIR )
Dim file
For Each file In folder.Files
cn.Execute "INSERT INTO [Sheet1$] SELECT * FROM [Excel 8.0;database=" & file & "].[Sheet1$]"
Next
End Sub