Adding a Hyperlink to a UserFormIf you use Excel 97, 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.
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" Download an ExampleI prepared a simple example that contains a UserForm that has two hyperlinks.
|