Hyperlink_Display full path file name instead of file name

josros60

Well-known Member
Joined
Jun 27, 2010
Messages
780
Office Version
  1. 365
Hi,

how can i modify the code below the title to display full path of file instead of filename?


VBA Code:
Sub NCL_EFT_BACKUP()
Dim fd As FileDialog
Dim FilePicked As Integer
Dim UserRange As Range, UserCell As Range
'loop through selecteditems from FileDialog and create hyperlink offsetting cell by 1 column each time
Dim ary



Set fd = Application.FileDialog(msoFileDialogFilePicker)
' Change initial folder as needed or store it in a cell and reference that
fd.InitialFileName = "\\mtlnas01\EFT_backup\2021\"

fd.AllowMultiSelect = True
FilePicked = fd.Show

If FilePicked = 0 Then
    MsgBox "You hit cancel"
Else
    'Using inputbox to get selected Range
    Set UserRange = Application.InputBox(Prompt:="Please Select a Cell", Title:="Cell Select", Type:=8)
    'Get first cell of selected range
    Set UserCell = UserRange.Cells(1)
    
    'loop through selecteditems from FileDialog and create hyperlink offsetting cell by 1 column each time
    For i = 1 To fd.SelectedItems.Count
    ary = Split(fd.SelectedItems(i), "\")
      UserCell.Hyperlinks.Add Anchor:=UserCell, Address:=fd.SelectedItems(i), TextToDisplay:=ary(UBound(ary))
      Set UserCell = UserCell.Offset(0, 1)
    Next
End If
End Sub

thank you,
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Do you mean you want the hyperlink text to show the full path?
 
Upvote 0
In that case try
VBA Code:
      UserCell.Hyperlinks.Add Anchor:=UserCell, Address:=fd.SelectedItems(i), TextToDisplay:=fd.SelectedItems(i)
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,466
Members
449,086
Latest member
kwindels

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top