I have an Excel file that I need to save copies of into several hundred folders within a tree structure. The master Excel file is at the top of the tree, and each copy has to be saved 5 folders down. Rather than explicitly state the folder names, I had hoped to use the VBA Dir statement to loop through all folders in the tree until I hit the bottom level. Sort of like this:
I had based this on my knowledge of DOS, where DIR *. returns a list of all directories. VBA's DIR statement doesn't seem to recognize directories, though. Can anyone suggest a workaround?
Thanks,
Johnny Geo
Code:
myPath = "c:\toplevel"
nextPath = dir(mypath & "*.")
do until nextPath = ""
myPath = nextPath
nextPath = dir(myPath & "*.")
Loop
I had based this on my knowledge of DOS, where DIR *. returns a list of all directories. VBA's DIR statement doesn't seem to recognize directories, though. Can anyone suggest a workaround?
Thanks,
Johnny Geo