Hi Norman,
I've tried the code and its work. I have created a CommandButton that will
direct to the ListFolders2.How should I modify the code so that the
CommandButton and the listed subfolder will display on the same page (let say,
in my sheet1 which I called as "Home").
I've tried to modify the code, but nothing shows up.
I'm very new to vba programming. ;(
- Cyzax -
Norman Jones wrote:
Hi Cyzax,
Try
'=============
Public Sub ListFolders2()
Dim SH As Worksheet
Dim FSO As Object
Dim StartFolder As Object
Dim Fldr As Object
Dim iCtr As Long
Const sName As String = "Folder List"
Dim sStartDir As String
sStartDir = InputBox( _
Prompt:="Enter the initial directory", _
Default:="C:\")
On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.Sheets(sName).Delete
Application.DisplayAlerts = True
Set SH = ThisWorkbook.Sheets. _
Add(after:=Sheets(Sheets.Count))
SH.Name = sName
Set FSO = CreateObject("Scripting.FileSystemObject")
Set StartFolder = FSO.GetFolder(sStartDir)
SH.Cells(1, "A").Value = sStartDir
For Each Fldr In StartFolder.SubFolders
iCtr = iCtr + 1
SH.Cells(iCtr + 1, "A").Value = Fldr.Name
Next Fldr
SH.Columns("A").AutoFit
End Sub
'<<=============
---
Regards,
Norman
Hi,
[quoted text clipped - 56 lines]
I have tried so many ways, but it doesn't works.
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200606/1