User Form Command Button to embed hyperlink to spreadsheet database

Gneissrocks

New Member
Joined
Dec 9, 2015
Messages
2
Hi,

I have a simple spreadsheet database where the second column of every row contains a hyperlink to a pdf. Each Hyperlink is unique for each row.

I want to add a command button to a user form that when clicked, allows the user to browse to the correct pdf and embed it as a hyperlink into the spreadsheet database in the correct cell. (cell 2 or every row in my case)

I know how to create a label that will follow the hyperlink once it is in the cell, but I am totally stuck on how to embed the hyperlink in the first place!

Hope someone can help.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I now have a working solution, but it is quite ugly.


<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">PrivateSub AddHyper_button_Click()
Dim URL AsString
URL
= Application.GetOpenFilename
Hyperlink_textbox
= URL
EndSub

PrivateSub Hyperlink_Label_Click()
Dim URL AsString
Dim cellvalue AsVariant

cellvalue
= Hyperlink_textbox.Value
URL
= cellvalue

OnErrorGoTo urlnotopen
ActiveWorkbook
.FollowHyperlink Address:=URL, NewWindow:=True
ExitSub
urlnotopen
:
MsgBox
"Cannot open "& URL
EndSub

</code>This finds the file address on button click, posts it to a text box on the form (which is hidden) which can be then written to the correct cell. There is also a label on the form which will follow the hyperlink to the correct file.
 
Upvote 0

Forum statistics

Threads
1,226,739
Messages
6,192,739
Members
453,754
Latest member
milestogo

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