Get hyperlink address

rjplante

Well-known Member
Joined
Oct 31, 2008
Messages
574
Office Version
  1. 365
Platform
  1. Windows
I would like to be able to open a dialog box, have the user select the file of interest, and then paste the file address into a particular cell.

The file would be located in the same folder the workbook is saved in, so I could use the something like thisworkbook.path to get the user to the desired folder. I just don't know the specific code to use.

Thanks for the help,

Robert


Here is what I have so far.

Rich (BB code):
Sub PDF_SETUP()

'If the link cell is blank...
If Range("Z40").Value = "" Then
   
    Dim mypath As String
    Dim myfile As String

    mypath = ThisWorkbook.Path
    
    'Display dialog box to get file address.
    myfile = ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= (Display dialogue box here to select file)_
        "some file here" , TextToDisplay:= "nice name here.pdf"

     Range("Z40").value = myfile

'If the link cell is not blank...
ElseIf Range("Z40").Value <> "" Then

    'Open file with link in cell Z40
    Worksheets("Intro Page").Range("Z40").Hyperlinks(1).Follow

End If

End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

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