Trevor G
Registered User.
- Local time
- Today, 19:12
- Joined
- Oct 1, 2009
- Messages
- 2,341
I have created the following code to loop through all excel workbooks in a folder but it is failing on the transferspreadsheet as it states the F1 field not found, having checked several times the workbooks are all structured correctly and the access table has the same field names as I created a temp table and copied the field names from the workbook.
Am I missing something simple or is this an issue with Access 2007 ?
Am I missing something simple or is this an issue with Access 2007 ?
Sub AddFileNew()
Dim strPath As String
Dim strFile As String
Dim i As Integer
strPath = CurrentProject.Path & "\"
strFile = Dir(strPath & "*.xls")
Do While strFile <> ""
i = i + 1
Debug.Print strFile
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "tblTempImport", strPath & strFile, True
strFile = Dir
Loop
MsgBox "How many files found " & i
End Sub