Adding A Hyperlink To A Userform

Category: UserForms | [Item URL]

A companion file is available: Click here to download

You probably know that the Insert Hyperlink command (or Ctrl+K) lets you insert a hyperlink into any cell. But if you've tried to add a hyperlink to a UserForm, you may have come up empty-handed.

There is no direct way to add a hyperlink to a UserForm, but you can simulate one by using the techniques described here. The figure below shows an example.


(Yes, this is a REALLY old screen shot!)

  1. Add a Label object and enter some text for its Caption
  2. Make the Label blue and underlined so it resembles a typical hyperlink. You might also want to set its font to Courier New.
  3. None of the standard mouse pointers resembles a pointing hand, so set the Label's MousePointer property to: 99 - fmMousePointerCustom
  4. Specify the cursor file for the Label's MouseIcon image. If you don't have a cursor file that resembles a pointing hand, click here to download a file named hand.cur.
  5. Double-click the Label and enter an event-handler subroutine for its Click event. The FollowHyperlink method is what makes it work. Here's an example of such a subroutine:
Private Sub Label1_Click()
    Link = "http://www.whitehouse.gov"
    On Error GoTo NoCanDo
    ActiveWorkbook.FollowHyperlink Address:=Link, NewWindow:=True
    Unload Me
    Exit Sub
NoCanDo:
    MsgBox "Cannot open " & Link
End Sub

To create a "mail to" hyperlink, use a statement like this:

    Link = "mailto:president@whitehouse.gov"


Search for Tips


All Tips

Browse Tips by Category

Tip Books

Needs tips? Here are two books, with nothing but tips:

Contains more than 100 useful tips and tricks for Excel 2013 | Other Excel 2013 books | Amazon link: 101 Excel 2013 Tips, Tricks & Timesavers

Contains more than 200 useful tips and tricks for Excel 2007 | Other Excel 2007 books | Amazon link: John Walkenbach's Favorite Excel 2007 Tips & Tricks

© Copyright 2016, J-Walk & Associates, Inc.
Privacy Policy