NickHK wrote:
OOPS,
Whilst there may be some caveat with using Dir recursively, that is NOT an
issue here.
NickHK
"NickHK" wrote in message
...
Dave,
At the risk of sounding pedantic, if you are in the position of learn code
like this, I wouldn't.
Scripting may be disabled on some systems and is notorious slow and
expensive. Also given the large number of versions that are floating
around,
you are not gaining anything from using this object that you can achieve
easily in VB/VBA's natively.
e.g.
Dim Filename As String
Filename = Dir("C:\", vbNormal)
Do While Filename < ""
Debug.Print Filename
Filename = Dir()
Loop
Whilst there may be some caveat with using Dir recursively, that is an
issue
here.
NickHK
Nick, thanks for your reply. Sorry it's taken so long for me to reply,
but I've been away on vacation for a week (in Costa Rica!).
I'm not sure how to apply your suggestion. What I am trying to do is to
examine the names of the folders in the selected directory which will
all be something like "SFY 05 Q1". I want to find the highest year,
then the highest Quarter within that year. If the Quarter is less than
4, I want to create a new directory with the highest year number and
the next quarter. If the highest year and quarter are "SFY 06 Q1", I
want to create a directory for "SFY 06 Q2" with several subdirectories.
Of course, if the highest quarter in any directory from the highest
year is 4th quarter, I want to create a folder for the next year, 1st
quarter. I assumed that someone sent me the scripting macro because I
can't do what I want with an XL macro. If that's not the case, I'd
prefer not to use scripting. But I don't know how to handle folders in
VBA. Do you have any further suggestions?
"davegb" wrote in message
oups.com...
I got this macro from Chip in reply to a post I made about going
through the sheets in a workbook. Can anyone tell me what it's supposed
to do, and why it isn't doing anything? Thanks.
Sub AAA()
Dim F As Scripting.file
Dim FF As Scripting.Folder
Dim FSO As Scripting.FileSystemObject
Set FSO = New Scripting.FileSystemObject
Set FF = FSO.GetFolder("H:\AllDocs\CFSR PIP DD\")
For Each F In FF.Files
Debug.Print F.Path
Next F
End Sub