My code searches folders and sub folders. I want to be able to exclude open files or system files when processing each file in these folders. Any help would be great!
Dim fso, oFolder, oSubfolder, oFile, queue As Collection
Set fso = CreateObject("Scripting.FileSystemObject")
Set queue = New Collection
queue.Add fso.GetFolder("folderpath")
Do While queue.Count > 0
Set oFolder = queue(1)
queue.Remove 1 'dequeue
For Each oSubfolder In oFolder.SubFolders
If UCase(oSubfolder.Name) <> "DO NOT USE" Then
queue.Add oSubfolder 'enqueue
Else
End If
Next oSubfolder
For Each oFile In oFolder.Files
'Process each file but exclude files such as "~xxxxxx" or thumbs.db or xxxx.tmp files
Next oFile
Loop