juan4412
07-14-2015, 01:47 PM
I know you can use this to search the directory listed, but how can you search sub-directories as well? And one caveat -- ignore (or not open) any directory that is like *Temp
Public Sub SearchDirectory()
Dim MyFolder As String
Dim MyFile As String
MyFolder = "L:\Excel"
MyFile = Dir(MyFolder & "\*.xlsx")
Do While MyFile <> ""
Workbooks.Open Filename:=MyFolder & "\" & MyFile
MyFile = Dir
Debug.Print MyFile
Loop
End Sub
Public Sub SearchDirectory()
Dim MyFolder As String
Dim MyFile As String
MyFolder = "L:\Excel"
MyFile = Dir(MyFolder & "\*.xlsx")
Do While MyFile <> ""
Workbooks.Open Filename:=MyFolder & "\" & MyFile
MyFile = Dir
Debug.Print MyFile
Loop
End Sub