Skipping Folders

T

Tom Moffatt

My question I believe is fairly simple. I am pulling filenames from a
directory but the next thing I have to do is pull file names from a specific
folder of each supplier. The folders I am trying to pull from have the same
name. I was using this code for just one folder.
______________________________________
Sub DIRECTORY()
With Application.FileSearch
.NewSearch
.LookIn = "Q:\Eng\LIBRARY\DRAWINGS"
.SearchSubFolders = True
.Filename = "*.dwg*"
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
ActiveSheet.Cells(i + 1, 1).Value = _
.FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
End Sub
________________________________________________________________
Now I wanna make an "in between" variable or function to skip the supplier
folder so I dont have to go through each and every one. I need to get into
the Inserts folder of each supplier basically.
_________________________________________________________________
Sub DIRECTORY()
With Application.FileSearch
.NewSearch

.LookIn = "Q:\Eng\LIBRARY\Supplier\ **VARIABLE FOLDER HERE** \INSERTS\"

.SearchSubFolders = True
.Filename = "*.dwg*"
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
ActiveSheet.Cells(i + 1, 1).Value = _
.FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
End Sub

THANKS IN ADVANCE
TOM M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top