Attribute VB_Name = "遍历文件夹和文件"
Option Explicit
Public Sub 遍历文件夹和文件(sFolder As String)
Dim fs As Object
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
File_Folder_List (fs.GetFolder(sFolder))
Set fs = Nothing
End Sub
Private Sub File_Folder_List(df As Object)
'循环处理文件集合
Dim objFile As Object,objSubFolder As Object
'文件集合
For Each objFile In df.Files
'
'
'文件处理过程
'
'
Next objFile
Set objFile = Nothing
'文件夹集合
For Each objSubFolder In df.SubFolders
'
'
'文件夹处理过程
'
'
File_Folder_List objSubFolder '递归循环处理文件夹
Next objSubFolder
Set objSubFolder = NothingEnd Sub