lmporting problem

  • Thread starter Thread starter ec
  • Start date Start date
E

ec

I have no idea how to import over 50 csv fils to Access.
Each one has the seperate table as the csv file name.
Please help.
 
This is based on code previously posted by Joe Fallon:

How to Import all Files in a Folder:

Public Sub ImportAllFiles()
'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("*.csv")
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, , _
Left(strFile, Len(strFile) - 4), _
"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