使用Excel.Application
オブジェクト、エクセルWorkbook
Worksheets
コレクション内のすべての名前から取得し、ワークブック内のシートのすべての名前を登録するには:
'Import all these worksheets:
Dim rst as DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblSheetNames")
Do While Not rst.Eof
'Link to SpreadSheet, **make sure you add the '!' to the spread-sheet-name for the *Range* parameter**
DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel12, "Temp", fileName, rst!ShtNm & "!"
'Dump sheet into table 'MyTable' and then Delete Link:
CurrenDb.TableDefs.Delete("Temp")
rst.MoveNext: Loop
:
Dim App As Object 'Excel interface
Dim File As Object 'Your file
Dim ws As Variant 'Your worksheet
Set App = CreateObject("Excel.Application") 'This opens excel application windows
Set File = App.Workbooks.Open(fileName) 'This opens your particular excel file (or workbook)
For each ws In File
'Register Name in a table named tblSheetNames, Containing a field named 'ShtNm':
CurrentDb.Execute "INSERT INTO tblSheetNames(ShtNm) VALUES ('" & ws.Name & "')"
Next
'Close the App to allow link to the Excel file
App.Close: Set App = Nothing
はその後、すべてのこれらのワークシートをインポートします
add the '!' to the spread-sheet-name for the Range parameter
どのようなエラーメッセージが表示されますか? – Karlomanio