Created
July 17, 2017 16:21
-
-
Save ndthanh/0ae0e75591a7a1ce1dcf006225e5168c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Sub Hyper() | |
'https://hocexcel.online | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment