Private Function f_FolderList(folderspec, Optional pstr = "*")
'遍历某文件夹下的文件夹,pstr用通配符指定筛选条件
Dim fs, f, f1, fc, i, arr
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.subfolders
ReDim arr(1 To fc.Count)
For Each f1 In fc
If f1.Name Like pstr Then
i = i + 1
arr(i) = f1.Name
End If
Next
ReDim Preserve arr(1 To i)
f_FolderList = arr
End Function