Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default sub directories again

Hello, I thought I should repost my question because the
message string was getting old so...

how can I
input a directory like "C:\Documents and Settings\" to a
program then have a program list (or output to a file) the
subdirectories?

Thanks in advanced


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default sub directories again

Mike,

Here is one way. It outputs the directories to a worksheet, indented as to
their levels

Dim FSO As Object
Dim cnt As Long
Dim level As Long
Dim arFiles

Sub Folders()
Dim i As Long

Set FSO = CreateObject("Scripting.FileSystemObject")

arFiles = Array()
cnt = 0
level = 1

ReDim arFiles(1, 0)
arFiles(0, 0) = "C:\myTest"
arFiles(1, 0) = level
SelectFiles "C:\myTest"

cnt = 0
For i = LBound(arFiles, 2) To UBound(arFiles, 2)
ActiveSheet.Cells(i + 1, arFiles(1, i)).Value = arFiles(0, i)
Next

End Sub

'---------------------------------------------------------------------------
----
Sub SelectFiles(sPath)
'---------------------------------------------------------------------------
----
Dim fldr As Object
Dim Folder As Object

Set Folder = FSO.Getfolder(sPath)
level = level + 1
For Each fldr In Folder.Subfolders
cnt = cnt + 1
ReDim Preserve arFiles(1, cnt)
arFiles(0, cnt) = fldr.Name
arFiles(1, cnt) = level
SelectFiles fldr.Path
level = level - 1
Next

End Sub

'---------------------------------
end-script ---------------------------------




--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mike" wrote in message
...
Hello, I thought I should repost my question because the
message string was getting old so...

how can I
input a directory like "C:\Documents and Settings\" to a
program then have a program list (or output to a file) the
subdirectories?

Thanks in advanced




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default sub directories again

Hi Mike
have a look at
http://tinyurl.com/yvvvm

Frank

Mike wrote:
Hello, I thought I should repost my question because the
message string was getting old so...

how can I
input a directory like "C:\Documents and Settings\" to a
program then have a program list (or output to a file) the
subdirectories?

Thanks in advanced



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
sub directories Mike Excel Programming 5 February 6th 04 10:15 PM
Directories Jeff[_24_] Excel Programming 4 January 20th 04 09:26 AM
changing directories Andrea[_7_] Excel Programming 2 November 5th 03 09:22 PM
Searching directories... Keith Willshaw Excel Programming 0 August 1st 03 09:20 AM
Searching directories... Phobos Excel Programming 0 August 1st 03 12:03 AM


All times are GMT +1. The time now is 07:09 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"