Importing multiple .CSV files into a Table

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
 
N

Nikos Yannacopoulos

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top