We help IT Professionals succeed at work.

How to add an hyperlink to a VB form?

dimensionav asked
I would like to know how to add an hyperlink in a form
Watch Question

Here is an answer from a PAQ:

Add a label with the following properties:

Name = lblHyperLink
Font set Underline
ForeColor = Blue
MousePointer = 10 - Up Arrow

And add this code:

Private Sub lblHyperLink_Click()
  Const cLinkVisited As Long = vbMagenta
  Shell ("cmd /c " & Chr$(34) & "Start " & lblHyperLink.Caption & Chr$(34))
  lblHyperLink.ForeColor = cLinkVisited
End Sub
I add a label to my form and double click on it, then in the code section, I add:-

ShellDocument "http://www.webaddress.com"

Of course, you should change the label text colour to dark blue and perhaps underline it too so it looks like a hyperlink
Oh, and using the same as my comment above, you can use the mailto feature, such as:-

ShellDocument "mailto:someone@somedomain.com"


I tried ShellDocument instruction but I got an error during compilation