omp001
10-25-2011, 04:04 AM
Hi all.
I'm using the code below to open all files '.xl*' from a folder (MyFolder).
However I have many sub folders level1 (about 25 of them) and many sub folders level2 (about 120).
How could I go with a code to open all '.xl*' files from MyFolder, from SubFolderLevel1 and from SubFolderLevel2 without needing to write the name of all that sub folders?
using XL 2007
something like:
myPath1="C:\MyFolder\"
myPath2="C:\MyFolder\*\"
myPath3="C:\MyFolder\*\*\"
Sub OpenAllXL()
Dim myFiles, myPath As String
myPath = "C:\MyFolder\SubFolderLevel1\SubFolderLevel2\"
myFiles = Dir(myPath)
Do While myFiles <> ""
If myFiles Like "*.xl*" Then
Workbooks.Open myPath & myFiles
End If
myFiles = Dir
MsgBox myFiles
Loop
End Sub
thnks in advance
I'm using the code below to open all files '.xl*' from a folder (MyFolder).
However I have many sub folders level1 (about 25 of them) and many sub folders level2 (about 120).
How could I go with a code to open all '.xl*' files from MyFolder, from SubFolderLevel1 and from SubFolderLevel2 without needing to write the name of all that sub folders?
using XL 2007
something like:
myPath1="C:\MyFolder\"
myPath2="C:\MyFolder\*\"
myPath3="C:\MyFolder\*\*\"
Sub OpenAllXL()
Dim myFiles, myPath As String
myPath = "C:\MyFolder\SubFolderLevel1\SubFolderLevel2\"
myFiles = Dir(myPath)
Do While myFiles <> ""
If myFiles Like "*.xl*" Then
Workbooks.Open myPath & myFiles
End If
myFiles = Dir
MsgBox myFiles
Loop
End Sub
thnks in advance