IS it possible to add Hyperlink to a commandbutton on a Userform

A

Ayo

I have a userform with a commandbutton. I want to add an hyperlink to the
commandbutton so that when the commandbutton is click, it opens up the
website. How do I go about doing that?
Thanks
 
D

Dave Peterson

Option Explicit
Private Sub CommandButton1_Click()
ThisWorkbook.FollowHyperlink Address:="http://www.microsoft.com"
End Sub

I think I'd use a label--format with blue font and underline--like a hyperlink
you'd see in the worksheet.
 
P

p45cal

Ayo;539341 said:
I have a userform with a commandbutton. I want to add an hyperlink to
the
commandbutton so that when the commandbutton is click, it opens up the
website. How do I go about doing that?
Thanks

double-click the button in the vbe and enter the following code where
the cursor flashes:

On Error GoTo NoCanDo
ActiveWorkbook.FollowHyperlink Address:="http://www.google.com",
NewWindow:=True
Exit Sub
NoCanDo:
MsgBox "Cannot open the link"
End Sub
 
A

Ayo

But how would I change the mouse to the pointing finger to stimulate clicking
the label?
 
R

Rick Rothstein

Select the Label control, then (in the Properties Window) set the
MousePointer property to 99-fmMousePointerCustom and then set the MouseIcon
property to a compatible ICO or CUR file (stay away from any marked "aero")
in your Windows/Cursors directory (there is a pointing hand cursor in there
that will work).
 
A

Ayo

Thanks so much Rick. Works great.

Rick Rothstein said:
Select the Label control, then (in the Properties Window) set the
MousePointer property to 99-fmMousePointerCustom and then set the MouseIcon
property to a compatible ICO or CUR file (stay away from any marked "aero")
in your Windows/Cursors directory (there is a pointing hand cursor in there
that will work).

--
Rick (MVP - Excel)




.
 
K

Kevin Angle

I'm trying to perform something similar in one of my projects. How do I
modify the "hyperlink" syntax to open an Excel file on the server
instead?

ThisWorkbook.FollowHyperlink
Address:="\\server\share\folder1\folder2\filename.xls"



*** Sent via Developersdex http://www.developersdex.com ***
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top