Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default How to List the names of the subfolders present in the folder (path of folder is given in the textbox by user )

Can any body help me with the code to find the names of the subfolders
present in the Folder whose path the user enters in the textbox.
When the user enters the path in the textbox , I want to display in a
LIST BOX the names of all the subfolders present in that folder . File
search returns the names of files in tht folder .. How do I get the
names of the sub folders in that folder?? Please let me know...

Cheers!!!
Divya

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default How to List the names of the subfolders present in the folder (path of folder is given in the textbox by user )

Divya:

I have used the shell command to get the list of folders...
e.g:

dim z as string
dim x as variant

z = "dir c:\mydir /a:d /b /sdirs.txt"
x = shell(z)

that gives me all the subfolders from c:\mydir in the text file
dirs.txt along with the entire path. (This text file is created under
c:\mydir)

Another cool way to do it is :
http://www.thescripts.com/forum/thread459690.html

refer to the second-last post on this thread...that also does it.

It uses the Dir function of VB recursively.

HTH
-Satish

divya wrote:
Can any body help me with the code to find the names of the subfolders
present in the Folder whose path the user enters in the textbox.
When the user enters the path in the textbox , I want to display in a
LIST BOX the names of all the subfolders present in that folder . File
search returns the names of files in tht folder .. How do I get the
names of the sub folders in that folder?? Please let me know...

Cheers!!!
Divya


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default How to List the names of the subfolders present in the folder (pat

See Excel Help for Dir Function example! You'll find there the very answre to
your question!

' Display the names in C:\ that represent directories.
MyPath = "c:\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName < "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName < "." And MyName < ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
Debug.Print MyName ' Display entry only if it
End If ' it represents a directory.
End If
MyName = Dir ' Get next entry.
Loop

Regards,
Stefi

€ždivya€ť ezt Ă*rta:

Can any body help me with the code to find the names of the subfolders
present in the Folder whose path the user enters in the textbox.
When the user enters the path in the textbox , I want to display in a
LIST BOX the names of all the subfolders present in that folder . File
search returns the names of files in tht folder .. How do I get the
names of the sub folders in that folder?? Please let me know...

Cheers!!!
Divya


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default How to List the names of the subfolders present in the folder (pat

Thanks a lot stefi and Satish for the quick reply.
Stefi wrote:
See Excel Help for Dir Function example! You'll find there the very answre to
your question!

' Display the names in C:\ that represent directories.
MyPath = "c:\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName < "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName < "." And MyName < ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
Debug.Print MyName ' Display entry only if it
End If ' it represents a directory.
End If
MyName = Dir ' Get next entry.
Loop

Regards,
Stefi

,,divya" ezt írta:

Can any body help me with the code to find the names of the subfolders
present in the Folder whose path the user enters in the textbox.
When the user enters the path in the textbox , I want to display in a
LIST BOX the names of all the subfolders present in that folder . File
search returns the names of files in tht folder .. How do I get the
names of the sub folders in that folder?? Please let me know...

Cheers!!!
Divya



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 to decide folder-depth or How to select more folders/subfolders (folder-tree) ? Subteam Excel Discussion (Misc queries) 2 May 7th 06 08:14 PM
please help me with folder and subfolders pieros Excel Programming 2 November 4th 05 12:52 PM
Delete all files within a folder (incl subfolders) Steph[_3_] Excel Programming 1 September 30th 04 09:59 PM
Create subfolders in a folder Myrna Rodriguez Excel Programming 2 July 15th 04 04:10 PM
Trouble making a report of all Files within a Folder and all Subfolders? SuperJas Excel Programming 2 April 2nd 04 02:41 AM


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