用递归的话思路很简单,
函数第一部分写遍历形参路径下的文件名
第二部分利用递归传入子文件夹內的路径
Function get_folder_file(pth) 'Dim fs As New FileSystemObject Set fso = CreateObject("Scripting.FileSystemObject").GetFolder(pth) For Each File In fso.Files '第一部分 last_row = Range("a65536").End(xlUp).Row + 1 Range("a" & last_row) = fso.Path Range("b" & last_row) = File.Name DoEvents Next For Each Folder In fso.SubFolders '第二部分 Call get_folder_file(Folder.Path) Next Set fso = Nothing End Sub Sub test() pth = "F:PYTHON2018PYTHON2018python3全栈3期老男孩三期 Python全栈104天 无密码" Call get_folder_file(pth) End Sub