GavZ
Mostly Beginners Luck!
- Local time
- Today, 06:36
- Joined
- May 4, 2007
- Messages
- 56
Hi,
I cannot seem to adapt the following code to import all worksheets in all Excel Files in a directory. It wil only import the first sheet in every file:
Thanks in advance..
I cannot seem to adapt the following code to import all worksheets in all Excel Files in a directory. It wil only import the first sheet in every file:
Code:
Const strPath As String = "C:\"
Dim strFile As String
Dim strFileList() As String '
Dim intFile As Integer '
strFile = Dir(strPath & "*.xls")
While strFile <> ""
intFile = intFile + 1
ReDim Preserve strFileList(1 To intFile)
strFileList(intFile) = strFile
strFile = Dir()
Wend
If intFile = 0 Then
MsgBox "No files found"
Exit Sub
End If
For intFile = 1 To UBound(strFileList)
DoCmd.TransferSpreadsheet acImport, , _
"t_temptable", strPath & strFileList(intFile), False
Next
MsgBox UBound(strFileList) & " Files were Imported"
Thanks in advance..