|
参与一下,超链接- Sub ykcbf() '//2024.7.24 获取文件夹名,作加上超链接
- Set fso = CreateObject("scripting.filesystemobject")
- Application.ScreenUpdating = False
- p = ThisWorkbook.Path & ""
- On Error Resume Next
- m = 1: n = 1
- [a2:c1000].Clear
- Columns("B:C").NumberFormatLocal = "@"
- For Each fd In fso.GetFolder(p).SubFolders
- m = m + 1
- Cells(m, 2) = fd.Name
- p1 = p & fd.Name & ""
- d1 = Cells(m, 2)
- ActiveSheet.Hyperlinks.Add Anchor:=Cells(m, 2), Address:="file://" & p1, TextToDisplay:=d1
- For Each fd1 In fd.SubFolders
- n = n + 1
- Cells(n, 3) = CStr(fd1.Name)
- p2 = p1 & fd1.Name & ""
- d2 = CStr(Cells(n, 3))
- ActiveSheet.Hyperlinks.Add Anchor:=Cells(n, 3), Address:="file://" & p2, TextToDisplay:=d2
- Next
- Next
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|