LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Network folder list

This function will enumerate all folders & subfolders beneath a given path,
UNC or mapped:

Function ListFolders(ByVal MyFolder As String)
Dim SubFold As Object, fso As Object, lst As String
Set fso = CreateObject("Scripting.FileSystemObject").GetFold er(MyFolder)
For Each SubFold In fso.SubFolders
ListFolders = ListFolders & "," & SubFold.Path
Select Case SubFold.Type
Case "File Folder"
lst = ListFolders(SubFold.Path)
If 0 < Len(lst) Then ListFolders = ListFolders & "," & lst
End Select
Next
ListFolders = Mid(ListFolders, 2)
Set fso = Nothing
Set SubFold = Nothing
End Function

NOTE:
1. This function is recursive: test it with a folder that is not too deep.
2. The function returns a comma delimited string.
3. The function does not check whether the argument you supply exists! If
this is an issue, use the PathFileExists API call to ensure that it does
exist.

USAGE:

xx = ListFolders("\\MyServer\MyPath")

or xx = ListFolders("c:\Winnt\System32")


" wrote:

I need some help with being able to programatically create a list of
all folders I have access to on a server. I am wanting to get this list
of directories (not files) using UNC paths. I have found all sorts of
topics on file searching and so no but not just for directories. I want
to be able to list all directories & sub-directories under
\\Myserver\Vol1\
Can someone point me in the right direction?


 
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
HyperLink to a folder on other drive on the same network (LAN) klj Excel Worksheet Functions 6 October 9th 09 02:50 PM
Folder Network drive Wanna Learn Excel Discussion (Misc queries) 1 May 30th 08 06:42 PM
SetUp Templates in Network Folder Rick Stambach Setting up and Configuration of Excel 0 December 7th 07 04:43 AM
Outlook attachment to network folder Ozzie via OfficeKB.com Excel Discussion (Misc queries) 2 February 3rd 06 11:19 AM
change curdir to a folder on a network [email protected] Excel Programming 2 October 9th 05 07:06 PM


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