Skip to content

Instantly share code, notes, and snippets.

@ndthanh
Created July 17, 2017 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndthanh/0ae0e75591a7a1ce1dcf006225e5168c to your computer and use it in GitHub Desktop.
Save ndthanh/0ae0e75591a7a1ce1dcf006225e5168c to your computer and use it in GitHub Desktop.
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