Hello,
We have a vendor that will supply us many files, and unfortunately will place them in different folders with no uniformity (within Windows Explorer).
I'd like to have the capability to find and open the file based on name, whether it's in a main folder, or one of the subfolders. I could use a wildcard based on the file I'm trying to open.
I.e. - File named "*Net Rebate*" will be in and of the following folders:
Main Folder
Subfolder 1
Subfolder 1a
Subfolder 1b
Subfolder 2
Subfolder 2a
Subfolder 2b
ect..... could be many subfolders.
How can I "Loop" through the main folder and all associated sub-folders to find a file "*Net Rebate*" and open it up?
So far I have:
On Error Resume Next
Dim i As Integer
With Application.FileSearch
.LookIn = ([RebDetail])
'* represents wildcard characters
.Filename = "*Net Rebate*.xls"
If .Execute > 0 Then 'Workbook exists
For i = 1 To .FoundFiles.Count
Workbooks.Open (.FoundFiles(i))
Next i
End If
End With
Any help would be appreciated!!!
Thank you.