一、按住 ALT + F11 键打开 Microsoft Visual Basic应用程序 窗口。
二、点击 插页 > 模块,然后将以下代码粘贴到 模块 窗口。
Sub Example1()
'Updateby Extendoffice
Dim xFSO As Object
Dim xFolder As Object
Dim xFile As Object
Dim xFiDialog As FileDialog
Dim xPath As String
Dim I As Integer
Set xFiDialog = Application.FileDialog(msoFileDialogFolderPicker)
If xFiDialog.Show = -1 Then
xPath = xFiDialog.SelectedItems(1)
End If
Set xFiDialog = Nothing
If xPath = "" Then Exit Sub
Set xFSO = CreateObject("Scripting.FileSystemObject")
Set xFolder = xFSO.GetFolder(xPath)
For Each xFile In xFolder.Files
I = I + 1
ActiveSheet.Hyperlinks.Add Cells(I, 1), xFile.Path, , , xFile.Name
Next
End Sub
三、按住 ALT + F8,快捷唤出模块。
感谢分享
谢谢大佬分享,谢谢!
又学习到了,写的非常好
谢谢大佬分享,谢谢!
感谢分享,让我好好学习一下
辛苦了,学习一下
真棒,感谢分享!
感谢分享
谢谢分享,学习了