Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default macro doesn't do anything

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default macro doesn't do anything

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.

--
Regards,
Tom Ogilvy


"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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default macro doesn't do anything


Tom Ogilvy wrote:
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.

--
Regards,
Tom Ogilvy


"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


Thanks, Tom!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default macro doesn't do anything

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


"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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default macro doesn't do anything

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


"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







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default macro doesn't do anything


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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 05:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"