|
Sub Test() '
Application.ScreenUpdating = False
Dim MyName, Dic, Did, I, T, F, TT, MyFileName
T = Timer
Set Dic = CreateObject("Scripting.Dictionary") '创建一个字典对象
Set Did = CreateObject("Scripting.Dictionary")
Set d = CreateObject("Scripting.Dictionary")
Set objShell = CreateObject("Shell.Application")
Set fs = CreateObject("Scripting.FileSystemObject")
Set objFolder = objShell.BrowseForFolder(0, "选择文件夹", 0, 0)
If objFolder Is Nothing Then MsgBox "您取消了操作!": Exit Sub
lj = objFolder.self.Path & "\"
Dic.Add (lj), ""
I = 0
Do While I < Dic.Count
Ke = Dic.keys '开始遍历字典
MyName = Dir(Ke(I), vbDirectory) '查找目录
Do While MyName <> ""
If MyName <> "." And MyName <> ".." Then
If (GetAttr(Ke(I) & MyName) And vbDirectory) = vbDirectory Then '如果是次级目录
Dic.Add (Ke(I) & MyName & "\"), "" '就往字典中添加这个次级目录名作为一个条目
End If
End If
MyName = Dir '继续遍历寻找
Loop
I = I + 1
Loop
For Each Ke In Dic.keys
MyFileName = Dir(Ke & "*.xls*")
Do While MyFileName <> ""
Did.Add (Ke & MyFileName), ""
MyFileName = Dir
Loop
Next
For Each k In Did.keys
If InStr(k, "小组") > 0 And InStr(k, "xlsx") > 0 Then
Kill k
End If
Next k
TT = Timer - T
MsgBox TT
Application.ScreenUpdating = True
End Sub |
|