Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default 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.




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
How do I turn off "Initializing Folders" every time I open a file. BIOYA_2000[_2_] Excel Discussion (Misc queries) 1 May 9th 09 05:56 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
"Search for files and folders" option doesnot work for 100% ECouwenberg Excel Discussion (Misc queries) 7 January 11th 06 04:50 PM
"Folder Select" Dialogue - Opening multiple files from selected folder Rob[_26_] Excel Programming 2 September 30th 05 02:47 PM
Backup to specific folder if workbook names begins with "NSR" or "MAC" GregR Excel Programming 3 May 6th 05 12:24 AM


All times are GMT +1. The time now is 11:55 AM.

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

About Us

"It's about Microsoft Excel"