Is it possible to pull files based on date using the Recursive Function? Below is the code I am using
Code:
Option Compare Database
Public Sub Command0_Click()
Dim MyFolder As String
Dim MyFile As String
Dim MyFolder2 As String
Dim DQ As String
Dim MyData As String
Dim myQueryName As String
Dim myExportFileName As String
Dim fso As Object
Dim fld As Folder
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.Title = ""
.AllowMultiSelect = False
intialfilename = ""
If .Show = True Then
For Each varfile In .SelectedItems
strFolder = varfile
Next
Else
rtn = SysCmd(4, "Action aborted by user")
Exit Sub
End If
End With
txtfolder = strFolder
Set fso = New FileSystemObject
Set fld = fso.GetFolder(strFolder)
RecursiveSearch fld
End Sub
Private Sub RecursiveSearch(fld As Folder)
Dim fold As Folder
Dim sysdate As Date
Dim fil As File
Dim strTemp As String
Dim colFolders As New Collection
Dim vFolderName As Variant
For Each fold In fld.SubFolders
txtresults = txtresults & "Folder: " & fold.Path & "" & vbCrLf
RecursiveSearch fold
Next
For Each fil In fld.Files
txtresults = txtresults & "File: " & fil.Path & vbCrLf
Next
End Sub
Last edited by a moderator: