H
hervinder
I Have this simple macro that will list all the files in a folder including
all the subfolders
Sub file_list()
With Application.FileSearch
..NewSearch
..LookIn = "C:\My Documents\"
..SearchSubFolders = True
..Filename = "*.*"
..FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
For I = 1 To .FoundFiles.Count
Cells(I, 1) = .FoundFiles(I)
Next I
Else
Cells(I, 1) = "No files Found"
End If
End With
End Sub
The folder i am looking in being, in this case being C:\My Documents\ has
many sub folders. I want it to list the files in all but two of them, is it
possible to modify the code to exlcude two specified subfolders. Something
along the lines of
If .subfolder ="sub1" then goto next
thanks in advance
Hervinder
all the subfolders
Sub file_list()
With Application.FileSearch
..NewSearch
..LookIn = "C:\My Documents\"
..SearchSubFolders = True
..Filename = "*.*"
..FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
For I = 1 To .FoundFiles.Count
Cells(I, 1) = .FoundFiles(I)
Next I
Else
Cells(I, 1) = "No files Found"
End If
End With
End Sub
The folder i am looking in being, in this case being C:\My Documents\ has
many sub folders. I want it to list the files in all but two of them, is it
possible to modify the code to exlcude two specified subfolders. Something
along the lines of
If .subfolder ="sub1" then goto next
thanks in advance
Hervinder