dim FSO as Scripting.FileSystemObject
dim fdrFolder as Scripting.Folder
dim fdrSubFolder as Scripting.Folder
Set FSO =New Scripting.FileSystemObject
ser fdrFolder = FSO.GetFolder(strPath)
For Each fdrSubFolder in fdrFolder.SubFolders
Print fdrSubFolder.name
next
'----------------------------------------------------------------
此过程能把指定文件夹下的文件名放入Sheet1的A列。
Public Sub findname()
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("d:\33") '在括号内输入你指定的目录
Set fc = f.Files
i = 1
For Each f1 In fc
Sheet1.Cells(i, 1) = f1.Name
i = i + 1
s = s & f1.Name
s = s & vbCrLf
Next
End Sub
'--------------------------------------------------------
Private Sub Form_Load()
'引用Microsoft script runtime
Dim f As File, fd As Folder
Set fd = fso.GetFolder("c:\")
For Each f In fd.Files
Debug.Print f.Path
Next
End Sub