|
参与一下。。。- Sub ykcbf() '//2023.12.29
- Dim fns As New Collection
- Set Fso = CreateObject("Scripting.FileSystemObject")
- With Application.FileDialog(msoFileDialogFolderPicker)
- .Title = "请选择文件夹"
- .InitialFileName = ThisWorkbook.Path & ""
- If .Show = -1 Then
- p = .SelectedItems(1) & ""
- End If
- End With
- Set ff = Fso.GetFolder(p)
- Call GetFiles(ff, fns, Fso)
- m = 1
- ActiveSheet.UsedRange.Offset(1).Clear
- For Each f In fns
- m = m + 1
- Cells(m, 1) = f(0)
- Cells(m, 2) = f(1)
- Cells(m, 3) = f(2)
- ActiveSheet.Hyperlinks.Add Anchor:=Cells(m, 2), Address:=f(3)
- Next
- Range("a1:c" & m).Borders.LineStyle = 1
- End Sub
- Function GetFiles(ff, fns, Fso)
- For Each f In ff.Files
- If InStr(f, "~$") = 0 Then
- If InStr(f, ThisWorkbook.Name) = 0 Then
- fns.Add Array(ff.Path, f.Name, "." & Fso.GetExtensionName(f), f.Path)
- End If
- End If
- Next
- For Each fd In ff.SubFolders
- Call GetFiles(fd, fns, Fso)
- Next
- End Function
复制代码
|
|