I'm using the following code to search for keywords in a filename, then populating a listbox. This can take quite a while if the user decides to search the entire hard drive. My question is: How can I stop this search programatically without raising an error?
Thanks,
Harold
***You can't change your past, but you can change your future***
Code:
Private Function FindFile(ByVal sFol As String, sFile As String) As Long
Dim tFld As Folder, tFil As File, FileName As String, Cnt As Long
Set fld = fso.GetFolder(sFol)
For Each tFil In fld.Files
For Cnt = 0 To 59
If InStr(1, tFil.Name, WordToScan(Cnt), vbTextCompare) Then
If InStr(1, tFil.Name, "dll", vbTextCompare) = False And InStr(1, tFil.Name, "mcr", vbTextCompare) = False And InStr(1, tFil.Name, "dle", vbTextCompare) = False Then
List1.AddItem fld.Path & "\" & tFil.Name
End If
End If
Next
y = y + 1
Label2.Caption = fld.Path & "/" & tFil.Name
DoEvents
Next
If fld.SubFolders.Count > 0 Then
For Each tFld In fld.SubFolders
DoEvents
FindFile = FindFile + FindFile(tFld.Path, sFile)
Label4.Caption = y
Next
Thanks,
Harold
***You can't change your past, but you can change your future***