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
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