Bonediggler1
Technical User
Hi,
I am writing a simple program that should loop through the files in a folder, import them and then move them to another folder.
I can get the import loop but do not quite know how to fit in the move part. Here's what I have so far...the code throws an error at the .foundfiles(i).move part.
Sub Blah_Import_and_Move()
'Determine folder and file to import
Dim strFileSource As String
Dim strFileName As String
strFileSource = "C:\Blah1\Blah2\Blah3\"
strFileName = "Blah *.*"
'Determine folder where to move files
Dim strMoveFolder As String
strMoveFolder = "c:\Blah4\Blah5\Blah6\"
'Import files and move to different folder after importing
Dim fs As Object
Set fs = Application.FileSearch
With fs
.lookin = strFileSource
.filename = "*.*"
If .Execute() > 0 Then
For i = 1 To .foundfiles.Count
DoCmd.TransferText acImportFixed, "Blah_Specs", "tblBlah_Raw", .foundfiles(1), False
.foundfiles(i).Move strMoveFolder
Next i
Else
GoTo ErrorHandler
End If
End With
End Sub
Thank you!!
I am writing a simple program that should loop through the files in a folder, import them and then move them to another folder.
I can get the import loop but do not quite know how to fit in the move part. Here's what I have so far...the code throws an error at the .foundfiles(i).move part.
Sub Blah_Import_and_Move()
'Determine folder and file to import
Dim strFileSource As String
Dim strFileName As String
strFileSource = "C:\Blah1\Blah2\Blah3\"
strFileName = "Blah *.*"
'Determine folder where to move files
Dim strMoveFolder As String
strMoveFolder = "c:\Blah4\Blah5\Blah6\"
'Import files and move to different folder after importing
Dim fs As Object
Set fs = Application.FileSearch
With fs
.lookin = strFileSource
.filename = "*.*"
If .Execute() > 0 Then
For i = 1 To .foundfiles.Count
DoCmd.TransferText acImportFixed, "Blah_Specs", "tblBlah_Raw", .foundfiles(1), False
.foundfiles(i).Move strMoveFolder
Next i
Else
GoTo ErrorHandler
End If
End With
End Sub
Thank you!!