Hyperlink a cell to a specific document

MO24

New Member
Joined
Mar 30, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hello,

I would like to be able to hyperlink a cell to a specific document but it isn't working for me, here's what I had in mind

I have already created an existing user form. It comes up with a range of textboxes that are linked to specific cells but what I would like to achieve is when the insert button is pushed it hyperlinks one of the cells (Cells(15,11))(Textbox name (AssessmentDescription) to a chosen document. It would be great if the user form could have a button that would open file explorer for you to pick a file (for this I was using Application.GetOpenFilename) and then copy the path of the chosen document so that it can be hyperlinked to it. I had created another textbox for it to insert the file path into to try to make it easier so that it could say:
VBA Code:
ActiveSheet.Hyperlinks.Add Anchor:=cells(15,11), Address:= LinkBox.Value
TextToDisplay:=AssessmentDescription.Value

Is this possible?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I would like to be able to hyperlink a cell to a specific document but it isn't working for me, here's what I had in mind
Sure it's possible. Why doesn't it work for you?
 
Upvote 0
Hello Dan,

All good. I have figured it out and forgot to update this thread. Thanks for your interest though.

For anyone else following this here is what I came up with

VBA Code:
Dim FileToOpen As String
FileToOpen = Application.GetOpenFilename
Link.Value = (FileToOpen)

ActiveWorkbook.Worksheets("Lists").Hyperlinks.Add Anchor:=Cells(15, 5), Address:=Link.Value
TextToDisplay = Description.Value

Thanks again. Appreciate it.
 
Upvote 0
That's great that you were able to solve it yourself! :)
Did you work out the source of the problem though?

Also, with the code above, you will likely need to make a slight change in order to get it to display the description text. The following code deals with that and also allows for the possibility that you might press cancel instead of selecting a file, and so exits the sub without displaying an error message:

VBA Code:
Sub AddHyperlink()
    
    Dim FileToOpen      As Variant
    
    FileToOpen = Application.GetOpenFileName
    If FileToOpen = False Then Exit Sub
    link.Value = CStr(FileToOpen)
    ActiveWorkbook.Worksheets("Lists").Hyperlinks.Add Anchor:=Cells(15, 5), Address:=link.Value, TextToDisplay:=Description.Value

End Sub
 
Upvote 0
Solution
Okay Thankyou,

I think I was just simply trying to approach it from the wrong angle. I started looking a bit further on google and used a couple of different strategies until I got it right.
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,138
Members
453,021
Latest member
Justyna P

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