Hey Guys,
I'm new to using Macros in Excel and am having problems.
Although I did not write this code, I believe that it's what I am looking for. I want to upload and append a ton of csv files, but I am getting a run-time error '424' object required message. This is the code:
Sub Import_multiple_csv_files()
Const strPath As String = "K:\My Documents\"
Dim strFile As String
Dim strFileList() As String
Dim intFile As Integer
strFile = Dir(strPath & "*.csv")
While strFile <> ""
intFile = intFile + 1
ReDim Preserve strFileList(1 To intFile)
strFileList(intFile) = strFile
strFile = Dir()
Wend
If intFile = 0 Then
MsgBox "No files found"
Exit Sub
End If
For intFile = 1 To UBound(strFileList)
DoCmd.TransferText acImportDelimi, , _
"Test", strPath & strFileList(intFile)
Next
MsgBox UBound(strFileList) & " Files were Imported"
End Sub
I'm not sure what to do, can you help me?
Bookmarks