Excel VBA 获取指定路径下的文件夹名称

Sub getfoldername() '获取指定路径下的文件夹名称
Dim fs As Object
n = 1
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.getfolder("C:\Lx\all")
For Each fd In f.subfolders
Cells(n, 1) = fd.Name
n = n + 1
Next
Set f = Nothing
Set fs = Nothing
End Sub

你可能感兴趣的:(Excel,VBA)