以下查询执行计算多个解压缩文件夹中的文件名的工作,但我想以这样的方式修改查询:它还包括压缩文件夹并计算这些文件夹中的文件名计数。
Sub count()
Range("B2").Value = getFileCount("\\hhhhh\ttttttt\kkkkkk")
Range("B3").Value = getFileCount("\\gggggg\xxxxxx\yyyyyyy")
End Sub
Function getFileCount(localRoot, Optional fld, Optional count As Long) As Long
Dim fso, f, baseFolder, subFolder, ftpFile, i
Set fso = CreateObject("Scripting.Filesystemobject")
If IsMissing(fld) Then
Set baseFolder = fso.GetFolder(localRoot)
Else
Set baseFolder = fld
End If
count = count + baseFolder.Files.count
For Each subFolder In baseFolder.SubFolders
getFileCount localRoot, subFolder, count
Next
getFileCount = count
End Function
如果您有任何问题或意见,请与我们联系。