hyperlink in vba msgbox

Posted on 2003-03-06
Medium Priority
Last Modified: 2012-05-05
I have a message box that appears when a button is clicked, in the message box is a contact email address and hyperlink to a url.  How can make these appear as real links (blue underlined) so that a user can just click on them?
Question by:kevin1973
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 11

Expert Comment

ID: 8082520
As far as I'm aware, there is no way to add an active hyperlink to a MsgBox. (this could be entirely incorrect, though)

But you can instead create a UserForm that looks the exact same as the message box then do this:

For each link (i.e. email, http) create a Label (i.e. Label1). Select the properties for the Label and set the font to blue/underlined. Then, in the Form's module, input this code.


Private Sub Label1_Click()

    Link = "http://www.expert-exchange.com"

    On Error GoTo Label1_Err
    ActiveWorkbook.FollowHyperlink Address:=Link, NewWindow:=True
    Unload Me
    Exit Sub

    MsgBox "Cannot open " & Link

End Sub


For email links you would use:

Link = "mailto:watyf@expert-exchange.com"

Basically you're making a custom "message box", and every time you need to display a link (for email or what have you) you just use a separate label for that text.


Expert Comment

ID: 8082691
You're trying to get blood out of a stone my man.

It's a messagebox object : it returns ok,yes,no or cancel. Thats it - it can do no more than that.

Where are the hyperlinks coming from?
Are they on a sheet?
LVL 11

Accepted Solution

WATYF earned 200 total points
ID: 8082714
sorry... I gave you some bad code in there... use this for the macro portion.


Private Sub Label1_Click()

    On Error GoTo Label1_Err
    HyprLnk = "http://www.experts-exchange.com"
    ActiveWorkbook.FollowHyperlink Address:=HyprLnk, NewWindow:=True
    Exit Sub

   MsgBox "Cannot open " & HyprLnk

End Sub



Author Comment

ID: 8083384
I never thought about creating a form for a custom message box.  Thanks for the idea, it worked perfectly.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question