Importing multiple .CSV files into a Table

  • Thread starter Thread starter jasperwt
  • Start date Start date
J

jasperwt

Hello

I have been importing .csv files into Access using a Macro which work
great. Unfortunately, the task has become more intense. I now hav
20-50 csv files to import the data from. The names of the file
change over time. The only redeeming thing is that the files are al
in the same directory. Does anyone have any ideas on how to automat
this

Thanks in advance for your help

Jaspe
 
Jasper,

You need some VBA code to retrieve the file names in the particular
directory, and import one by one. Here's some sample (untested) code:

Dim fs, fldr, fls, fl
Set fs = CreateObject("Scripting.FileSystemObject")
Set fldr = fs.getfolder("C:\temp\")
Set fls = fldr.files
For Each fl In fls
If Right(fl.Name, 4) = ".CSV" Then
DoCmd.TransferText acImportDelim, "YourSpec", _
"TargetTable", fl.Name
End If
Next fl

HTH,
Nikos
 
Back
Top