Accessing Excel files within multiple levels of a directory
You'll want to write a function that takes a directory name, puts
together a list of all directories in it, calls itself for each of
those directories, then opens all the files in that directory. You'll
end up with all files in folder 1A1 opened first, then 1A2, then 1A,
then 1B1, then 1B2, then 1B, then 1.
Public Function OpenBigDir(DirName As String)
'Get array of directories under DirName
'If array contains more than zero directories
For each Dir in DirArray
OpenBigDir(Dir)
Next Dir
'Get array of files.
'If array contains more than zero files
For each File in Filearray
Open File
Next file
End Function
Let me know if you need more help than that.
On May 15, 1:02 pm, Barb Reinhardt
wrote:
Let's say I have a directory structure like this:
FOLDER1
FOLDER 1A
FOLDER 1A1
FOLDER 1A2
FOLDER 1B
FOLDER 1B1
FOLDER 1B2
I want to be able to select a high level folder and then open all XLS
workbooks that are in every folder below it. I'm not even sure how to begin
with this.
Also, I think I've seen somewhere that there's a way to allow the user to
CANCEL during execution of a macro. How do I do that?
Thanks in advance,
Barb Reinhardt
|