I am using the ===CODE=== at the bottom of this message (lifted from somewhere) to import >5000 CSV formated datafiles into one table. No problem with this part.
I have been struggling with the code to append the file name (minus extention to each record.
I believe that I can use the follow code to get the filename:
filename = Left(ImportFile, (InStr(1, ImportFile, ".") - 1))
I am competely at a loss as to how to proceed from here.
Suggestion please?
============CODE===============
Private Sub Command0_Click()
Dim InputDir, ImportFile As String, tblName As String, filename As String
InputDir = "C:\"
ImportFile = Dir(InputDir & "\*.csv")
SheetName = shtName
Do While Len(ImportFile) > 0
'Select: Import all files into file
tblName = "Uncorrected Ticker Data"
'Select:Import csv
DoCmd.TransferText acImportDelim, "Import Specification", tblName, InputDir & ImportFile, False
ImportFile = Dir
Loop
End Sub
I have been struggling with the code to append the file name (minus extention to each record.
I believe that I can use the follow code to get the filename:
filename = Left(ImportFile, (InStr(1, ImportFile, ".") - 1))
I am competely at a loss as to how to proceed from here.
Suggestion please?
============CODE===============
Private Sub Command0_Click()
Dim InputDir, ImportFile As String, tblName As String, filename As String
InputDir = "C:\"
ImportFile = Dir(InputDir & "\*.csv")
SheetName = shtName
Do While Len(ImportFile) > 0
'Select: Import all files into file
tblName = "Uncorrected Ticker Data"
'Select:Import csv
DoCmd.TransferText acImportDelim, "Import Specification", tblName, InputDir & ImportFile, False
ImportFile = Dir
Loop
End Sub