ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to go through a series of folders without using "folder"? (https://www.excelbanter.com/excel-programming/353194-how-go-through-series-folders-without-using-folder.html)

davegb

How to go through a series of folders without using "folder"?
 
I want to go through all the subfolders of a certain folder and compare
a variable in the folder names. I looked here for a way to do this, but
the code I found used "folder" (object, property, method?) which I
don't have in XL2000. Is there a way around this? Or is there an add-in
that will add that object/property/method?
Thanks for your help.


Chip Pearson

How to go through a series of folders without using "folder"?
 
In VBA, go to the Tools menu, choose References, and put a check
next to "Windows Scripting Runtime". Then you can use code like
the following:

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:\Test")
For Each F In FF.Files
Debug.Print F.Name
Next F
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"davegb" wrote in message
ups.com...
I want to go through all the subfolders of a certain folder and
compare
a variable in the folder names. I looked here for a way to do
this, but
the code I found used "folder" (object, property, method?)
which I
don't have in XL2000. Is there a way around this? Or is there
an add-in
that will add that object/property/method?
Thanks for your help.




Chip Pearson

How to go through a series of folders without using "folder"?
 
Debug.Print F.Name

If you want the complete filename, including the folder(s), use

Debug.Print F.Path


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Chip Pearson" wrote in message
...
In VBA, go to the Tools menu, choose References, and put a
check next to "Windows Scripting Runtime". Then you can use
code like the following:

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:\Test")
For Each F In FF.Files
Debug.Print F.Name
Next F
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"davegb" wrote in message
ups.com...
I want to go through all the subfolders of a certain folder and
compare
a variable in the folder names. I looked here for a way to do
this, but
the code I found used "folder" (object, property, method?)
which I
don't have in XL2000. Is there a way around this? Or is there
an add-in
that will add that object/property/method?
Thanks for your help.






davegb

How to go through a series of folders without using "folder"?
 

Chip Pearson wrote:
Debug.Print F.Name


If you want the complete filename, including the folder(s), use

Debug.Print F.Path


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Chip Pearson" wrote in message
...
In VBA, go to the Tools menu, choose References, and put a
check next to "Windows Scripting Runtime". Then you can use
code like the following:

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:\Test")
For Each F In FF.Files
Debug.Print F.Name
Next F
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


Chip, thanks for you help. "References" is not availble in the menu,
grayed out. Any suggestions?





"davegb" wrote in message
ups.com...
I want to go through all the subfolders of a certain folder and
compare
a variable in the folder names. I looked here for a way to do
this, but
the code I found used "folder" (object, property, method?)
which I
don't have in XL2000. Is there a way around this? Or is there
an add-in
that will add that object/property/method?
Thanks for your help.






All times are GMT +1. The time now is 08:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com