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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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,223,893
Messages
6,175,239
Members
452,621
Latest member
Laura_PinksBTHFT

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