Function FindAndImportFiles(vDirectory As Variant, vFileSpec As Variant)
'PK - 11/10/09
'//////////////////
'Note: Cycles through files in a given folder/directory and filespec.
'Imports all files (see ImportTheFile).
'//////////////////
'Note: directory and filespec passed from ImportForm
'Directory = "F:\Data\Databases\Heather\ImportFiles"
'FileSpec = "xls"
Dim QI As Integer
QI = MsgBox("Confirm importing all xls files from directory: " & vDirectory, vbYesNo)
If QI = vbNo Then Exit Function
Directory = vDirectory
FileSpec = vFileSpec
Dim NumFound As Long
With Application.FileSearch
.NewSearch
.LookIn = Directory
.FileName = FileSpec
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Call ImportTheFile(.FoundFiles(i))
Next i
End If
End With
'Now append all the newly imported file names to a table.
DoCmd.SetWarnings False
DoCmd.OpenQuery "ImportedFileListingMake"
DoCmd.SetWarnings True
MsgBox "Import Routine complete! All tables in the designated folder have been imported!"
End Function