我有以下代码,我想获取水平列出的各个文件夹中的文件。如何修改此代码,以便对于 A 列中的给定文件路径,我从 C 列中获取此列中的文件?我的知识只允许我为一个文件夹执行此操作(而不是我希望它查看的 150 个文件夹)
`enter code here`
Sub ListFiles()
iCol = 3
Call ListMyFiles(Range("A5"), Range("B5"))
End Sub
Sub ListMyFiles(mySourcePath, IncludeSubfolders)
Set MyObject = New Scripting.FileSystemObject
Set mySource = MyObject.GetFolder(mySourcePath)
On Error Resume Next
For Each myFile In mySource.Files
iRow = 5
Cells(iRow, iCol).Value = myFile.Name
iCol = iCol + 1
Next
If IncludeSubfolders Then
For Each mySubFolder In mySource.SubFolders
Call ListMyFiles(mySubFolder.Path, True)
Next
End If
End Sub