Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing multiple txt files

Status
Not open for further replies.

MattBegg

Programmer
Jan 19, 2001
42
CA
How could I go about importing many csv files all with the same structure but there is no commonality between the files names, onlt the extension.

I would imagine the logic would be to loop through each file in the directory until all have been processed, but at the moment I cannot think of the code, any help would be much appreciated. Regards

Matt

matt@begg-uk.co.uk
 
build an Import Specification for the Import (since they are all the same structure, only one will be needed), loop thru the directory, and when a file with "cvs" is found, Import it. You'll need to figure out how to name your tables, this example uses "tbl" and the FileName without the path and extension. This is untested as to the Importing, but works with the MessageBox.

Dim strFile As String, strTable as string
strFile = Dir("c:\")
Do While Len(strFile) > 0
If Right(strFile, 3) = "cvs" Then
strTable = "tbl" & Left(strFile, Len(strFile) - 4)
MsgBox "File Name is " & strFile & ", " & strTablestrFile
' DoCmd.TransferText , "Specification Name", strTable, strFile
End If
strFile = Dir
Loop

PaulF
 
cheers PaulF

I had gone a bit brain dead :(

Regards

Matt

matt@begg-uk.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top