VBA实现递归遍历所选中的路径,并将该路径下文件及子文件夹中所有文件路径列出在第一列,求大神帮忙。
答案:1 悬赏:60 手机版
解决时间 2021-02-28 11:47
- 提问者网友:喧嚣尘世
- 2021-02-28 08:16
VBA实现递归遍历所选中的路径,并将该路径下文件及子文件夹中所有文件路径列出在第一列,求大神帮忙。
最佳答案
- 五星知识达人网友:独行浪子会拥风
- 2021-02-28 08:52
您能提出这等 问题说明您的VBA水平有一定火候了,请看
Function Fllst(Pth$)
Dim Fso As Object
Dim Fld, Fl
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Fld = Fso.getfolder(Pth)
On Error Resume Next
For Each Fl In Fld.Files
[A65536].End(3)(2) = Fl.path
Next
For Each Fl In Fld.SubFolders
Fllst (Fl.path)
Next
End Function
Sub getList()
Dim Fso As Object
Set Fso = CreateObject("Scripting.FileSystemObject")
[A:A].ClearContents
Application.ScreenUpdating = False
Fllst (CreateObject("Shell.Application").BrowseForFolder(0, "请选择目录", 0, "").Self.path)
Application.ScreenUpdating = True
Set Fso = Nothing
End Sub
Function Fllst(Pth$)
Dim Fso As Object
Dim Fld, Fl
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Fld = Fso.getfolder(Pth)
On Error Resume Next
For Each Fl In Fld.Files
[A65536].End(3)(2) = Fl.path
Next
For Each Fl In Fld.SubFolders
Fllst (Fl.path)
Next
End Function
Sub getList()
Dim Fso As Object
Set Fso = CreateObject("Scripting.FileSystemObject")
[A:A].ClearContents
Application.ScreenUpdating = False
Fllst (CreateObject("Shell.Application").BrowseForFolder(0, "请选择目录", 0, "").Self.path)
Application.ScreenUpdating = True
Set Fso = Nothing
End Sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯