Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro recorded... tabs & file names changed, macro hangs | Excel Worksheet Functions | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
how to count/sum by function/macro to get the number of record to do copy/paste in macro | Excel Programming | |||
macro to delete entire rows when column A is blank ...a quick macro | Excel Programming | |||
Start Macro / Stop Macro / Restart Macro | Excel Programming |