Import Multiple Files From Folder

  • Thread starter Thread starter Keith H. Cowan
  • Start date Start date
K

Keith H. Cowan

Greetings,

I need to import multiple files from one folder. I am using the
"Application.Dialog(4)" to identify the folder. How do I access the files in
that folder to do a "docmd.transfertext"? I believe I should be able to do a
"For Each" file in the folder. Any help would be appreciated.

Thanks

Keith
 
How to Import all Files in a Folder:

Private Sub btnImportAllFiles_Click()
'procedure to import all files in a directory and delete them.
'assumes they are all the correct format for an ASCII delimited import.
Dim strfile As String

ChDir ("c:\MyFiles")
strfile = Dir("FileName*.*")
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, "ImportSpecName", "AccessTableName",
"c:\MyFiles\" & strfile, True
'delete the file (consider moving it to an Archive folder instead.)
Kill "c:\MyFiles\" & strfile
strfile = Dir
Loop

End Sub
 
Back
Top