内容如上:

解决方案 »

  1.   

    '查找特定路径下某种类型文件,将名称保存在数组中,Ubound(数组)的值即为文件个数
    Sub aaa()
        Dim strFileName() As String
        Dim FileName As String
        Dim j As Long
        j = -1
        FileName = Dir(你的路径 & "*.*")
        Do While FileName <> ""
             If FileName <> "." And FileName <> ".." Then
                  j = j + 1
                  ReDim Preserve strFileName(j + 1)
                  strFileName(j) = FileName
             End If
             FileName = Dir   ' 查找下一个文件。
        Loop
    End Sub
    '搜索文件夹
    Public Sub ShowFloder(strDir As String, objDir As Object)
        On Error Resume Next
        Dim lngCount As Long
        Dim i As Long
        Dim strPath As String
        
        
        With objDir
            .Path = strDir
            lngCount = .ListCount
            For i = 0 To lngCount - 1
                .Path = strDir
                
                strPath = .List(i)      ''取得当前子目录
                
                '获得一个目录字符串
                '可以在此调用查找文件函数
                
                Call ShowFloder(strPath, objDir)    ''递归寻找
            Next
        End With
    End Sub