问题描述
尝试使下面的代码适应
修复了以下拼写错误:
解决方法
如果2020已经包含在子文件夹名称中,则可以尝试 剩下的功能...
rgds
,
'lists information about the folders in SourceFolder
' example: ListSubFolders "C:","2020*"
Sub ListSubFolders(SourceFolderName As String,Optional pattern as string="")
Dim FSO As Scripting.FileSystemObject
Dim sf As Scripting.Folder,c As Range
Set c = sheets("Folders").Cells(rows.count,1).End(xlup).offset(1,0)
Set FSO = New Scripting.FileSystemObject
For Each sf In FSO.GetFolder(SourceFolderName).SubFolders
If Len(pattern)=0 or SourceFolder.Name Like pattern Then
' display folder properties
c.Resize(1,7).Value= Array( _
sf.Path,sf.Name,sf.Size,sf.SubFolders.Count,_
sf.Files.Count,sf.ShortName,sf.ShortPath)
End If
Set c = c.offset(1,0)
Next SubFolder
End Sub