|
老师,请问我想统计某个文件夹内不同文件类型对应的个数,请问怎么实现呢?
文件类型已可获取,代码如下(本段代码在PPT中编写完成):
Sub 文件类型统计()
'选定文件夹
Dim a
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "选择文件夹", 0, 0)
If Not objFolder Is Nothing Then
a = objFolder.self.Path
End If
Set objFolder = Nothing
Set objShell = Nothing
'遍历文件
Dim n, bk, bkn, bknn
n = 1
bknn = "/"
bk = Dir(a & "\*.*") '文件名
Do While bk <> "" And bk <> Application.ActivePresentation.Name '遍历。如果myfile不篁空或不等于它自己
bkn = Right(bk, Len(bk) - InStrRev(bk, ".")) 'InStrRev(bk,"."))从字串末尾找出"."的位置
bknn = bknn & bkn & "/"
bk = Dir '找寻下一个文件
n = n + 1 '计数、累加
Loop
MsgBox bknn
End Sub
盼复,谢谢!
|
|