macro doesn't do anything

D

davegb

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
 
T

Tom Ogilvy

It will list the files in the folder H:\AllDocs\CFSR PIP DD\

In the VBE, go to View and select immediate window. This should open a
window at the bottom of the VBE. The output of the code will be placed
there.
 
D

davegb

Tom said:
It will list the files in the folder H:\AllDocs\CFSR PIP DD\

In the VBE, go to View and select immediate window. This should open a
window at the bottom of the VBE. The output of the code will be placed
there.

Thanks, Tom!
 
N

NickHK

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
 
N

NickHK

OOPS,
Whilst there may be some caveat with using Dir recursively, that is NOT an
issue here.

NickHK
 
D

davegb

NickHK said:
OOPS,
Whilst there may be some caveat with using Dir recursively, that is NOT 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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top