|
参与一下。。。
- Sub ykcbf() '//2024.8.21
- Application.ScreenUpdating = False
- Set fso = CreateObject("Scripting.FileSystemObject")
- ' p = CreateObject("Wscript.Shell").SpecialFolders("Desktop") & "" '//桌面路径
- p = ThisWorkbook.Path & "" '//实际使用时,把这句换成上面那句
- ReDim brr(1 To 10000, 1 To 1)
- With Application.FileDialog(msoFileDialogFolderPicker)
- .Title = "请选择文件夹"
- .InitialFileName = p
- If .Show = -1 Then
- p = .SelectedItems(1) & ""
- End If
- End With
- fn = Application.InputBox("请输入子文件夹名", "子文件夹名", "")
- If Len(fn) = 0 Then Exit Sub
- getfiles p, brr, m, fso
- With Sheets("Sheet1")
- .[a2].Resize(10000, 1) = ""
- .[a2].Resize(m, 1) = brr
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
- Function getfiles(p, brr, m, fso)
- For Each fd In fso.GetFolder(p).SubFolders
- If InStr(fd.Name, fn) Then
- For Each f In fd.Files
- m = m + 1
- brr(m, 1) = fd.Name & ":" & fso.GetBaseName(f)
- Next
- getfiles fd, brr, m, fso
- End If
- Next
- End Function
复制代码
|
评分
-
1
查看全部评分
-
|