Hi
This is my first post and i normally only do VBA in excel so go easy on me
I'm trying to use a code for the first time in Access 2010 which uses the now retired 'Application.FileSearch'. I've tried solutions from other posts but cant get the thing to work.
Heres the code below, its only a simple bit of code to import csv files into access.
Any help would be greatly appreciated
Thanks
Ben
This is my first post and i normally only do VBA in excel so go easy on me

I'm trying to use a code for the first time in Access 2010 which uses the now retired 'Application.FileSearch'. I've tried solutions from other posts but cant get the thing to work.
Heres the code below, its only a simple bit of code to import csv files into access.
PHP:
Sub Import_DMA_CSV()
Dim myarray()
Dim fs As Object
Dim i As Integer
Dim Message As String
Set fs = Application.FileSearch
fs.LookIn = "C:\Temp"
fs.filename = "*.csv"
If fs.Execute > 0 Then
ReDim myarray(fs.foundfiles.Count)
For i = 1 To fs.foundfiles.Count
myarray(i) = fs.foundfiles(i)
txt1 = myarray(i)
DoCmd.TransferText acImportDelim, "STW Import", Mid(myarray(i), 9, 7), myarray(i), False
Next i
Else
MsgBox "No files were found"
Exit Sub
End If
Message = MsgBox("Import Complete!", vbOKOnly)
End Sub
Any help would be greatly appreciated

Thanks
Ben