View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_7_] Bob Phillips[_7_] is offline
external usenet poster
 
Posts: 1,120
Default Sub folder lList

Hi Greg,

Try this

Sub FolderListing()
Dim i As Long
Dim oFSO As Object
Dim oFolder As Object
Dim oFldr As Object
Dim sOld As String

Set oFSO = CreateObject("Scripting.FileSystemObject")
i = 2
On Error Resume Next
Worksheets.Add.Name = "Folders"
On Error GoTo 0
ActiveSheet.Cells.ClearContents
Range("A1").Value = "Folder Name"

Set oFolder = oFSO.GetFolder("C:\MyTest")
For Each oFldr In oFolder.subFolders
Cells(i, "A").Value = oFldr.Path
i = i + 1
Next oFldr
Columns(1).AutoFit

End Sub



--
HTH

Bob Phillips

"GregR" wrote in message
oups.com...
I want to copy the names of sub folders from a specific folder to a new
sheet in an existing workbook. I have subfoders under the named
subfolders I want copied, but don't want those, just one branch of a
tree directory so to speak. TIA

Greg