Sub ImportAllSheets()
Dim objXL As Object
Dim sTable, xlPath As String, i As Integer
xlPath = "C:\myExcel.xls"
Set objXL = CreateObject("Excel.Application")
objXL.Workbooks.Open xlPath , , True
With objXL
For i = 1 To .Worksheets.Count
if instr(.Worksheets(i).Name,"widget") then
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, _
"TestTable", xlPath, True, .Worksheets(i).Name & "!A:D"
end if
Next
End With
objXL.Quit
Set objXL = Nothing
End Sub
|