Public arr1, y% Sub peng() ReDim arr1(1 To 65536, 1 To 1) y = 0 Call xi("*", ActiveWorkbook.Path) Cells(1, 1).Resize(y, 1) = arr1 End Sub 'a查询文件条件设置 'pt路径设置 Sub xi(a, pt) On Error GoTo ren Dim x%, i% Dim d As New Dictionary dirs = Dir(pt & "\" & a) Do While dirs <> "" y = y + 1 d(dirs) = "" arr1(y, 1) = pt & "\" & dirs dirs = Dir Loop ReDim arr(1 To 100) dirs = Dir(pt & "\", vbDirectory) Do While dirs <> "" If dirs <> "." And dirs <> ".." And Not d.Exists(dirs) Then x = x + 1 If x > UBound(arr) Then ReDim Preserve arr(1 To UBound(arr) + 100) arr(x) = pt & "\" & dirs End If dirs = Dir Loop For i = 1 To UBound(arr) If arr(i) = "" Then Exit Sub Call xi(a, arr(i)) Next i ren: End Sub
对速度进行了优化.
[此贴子已经被作者于2008-5-29 8:44:04编辑过] |