I'm writing some code to read a list of filenames from a text file and searching for the filename in a folder and sub folders. The following code works but it only search 1 folder how can i get it to search any subfolders.
thanks
Private Sub cmdCheck_Click()
Dim strFilename As String
Dim strCheckFile As String
Dim strResult As String
Dim strCheckPath As String
strCheckPath = txtPathToCheck
Open txtFilename For Input As #1
Do While Not EOF(1)
Input #1, strCheckFile
strResult = ""
' Check all folders
If strResult = "" Then
strResult = Dir(strCheckPath & strCheckFile)
End If
If strResult <> "" Then
FileCopy strCheckPath & strCheckFile, txtNewLocation & strCheckFile
Else
Open txtNewLocation & "Missing Files.txt" For Append As #2
Print #2, strCheckFile & " is missing"
Close #2
End If
Loop
Close #1
MsgBox "Done"
End Sub
thanks
Private Sub cmdCheck_Click()
Dim strFilename As String
Dim strCheckFile As String
Dim strResult As String
Dim strCheckPath As String
strCheckPath = txtPathToCheck
Open txtFilename For Input As #1
Do While Not EOF(1)
Input #1, strCheckFile
strResult = ""
' Check all folders
If strResult = "" Then
strResult = Dir(strCheckPath & strCheckFile)
End If
If strResult <> "" Then
FileCopy strCheckPath & strCheckFile, txtNewLocation & strCheckFile
Else
Open txtNewLocation & "Missing Files.txt" For Append As #2
Print #2, strCheckFile & " is missing"
Close #2
End If
Loop
Close #1
MsgBox "Done"
End Sub