K
kaiser
Hi all
I am trying to create a list of folders but not sub folders in excel.
For example, If i have a folder with the path c:\test\
and in test there are three folders ("Folder1, Folder2, Folder3") and
Folder1 has a folder in in called "Folder1.1" i want the output to be
c:\test\folder
c:\test\folder1
c:\test\folder2
c:\test\folder3
I have the following code from this forum. HOw do i ammend it to not
include sub folders?
Set a reference (in VBA, Tools menu, References item) to
Microsoft Scripting Library and use code like the following:
Sub Start()
Dim FSO As Scripting.FileSystemObject
Dim TopFolder As Scripting.Folder
Set FSO = New Scripting.FileSystemObject
Set TopFolder = FSO.GetFolder("C:\Temp")
DoOneFolder TopFolder
End Sub
Sub DoOneFolder(F As Scripting.Folder)
Dim OneFolder As Scripting.Folder
'
' do something with F
Debug.Print F.Path
For Each OneFolder In F.SubFolders
DoOneFolder OneFolder
Next OneFolder
End Sub
I am trying to create a list of folders but not sub folders in excel.
For example, If i have a folder with the path c:\test\
and in test there are three folders ("Folder1, Folder2, Folder3") and
Folder1 has a folder in in called "Folder1.1" i want the output to be
c:\test\folder
c:\test\folder1
c:\test\folder2
c:\test\folder3
I have the following code from this forum. HOw do i ammend it to not
include sub folders?
Set a reference (in VBA, Tools menu, References item) to
Microsoft Scripting Library and use code like the following:
Sub Start()
Dim FSO As Scripting.FileSystemObject
Dim TopFolder As Scripting.Folder
Set FSO = New Scripting.FileSystemObject
Set TopFolder = FSO.GetFolder("C:\Temp")
DoOneFolder TopFolder
End Sub
Sub DoOneFolder(F As Scripting.Folder)
Dim OneFolder As Scripting.Folder
'
' do something with F
Debug.Print F.Path
For Each OneFolder In F.SubFolders
DoOneFolder OneFolder
Next OneFolder
End Sub