how to put hyperlink on message box

jaik22

Board Regular
Joined
Sep 23, 2016
Messages
102
Code:
Sub Report()
MsgBox "Report is ready to use"
End Sub

So far I have something like this, but I would like to add a hyperlink of report's path.
If the report's path is C:\Program Files\Acute Data_1000.xlsx is it possible to include a hyperlink on the message box?

Thank you!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
You can't add a hyperlink to a message box.

What you could do though is have the code hyperlink to the report, perhaps when the user clicks Yes in the message box.
Code:
Sub Report()
Dim Resp As VbMsgBoxResult

    Resp = MsgBox("Report is ready to use. Do you want to view it?", vbInformation + vbYesNo, "Report ready")


    If Resp = vbYes Then
        ThisWorkbook.FollowHyperlink "C:\Program Files\Acute Data_1000.xlsx"
    End If
    
End Sub
 
Upvote 0
Hey Norie thanks for the tip, but I am getting object error on code below. Do I have to add something?

Thank you so much for your support!

Code:
ThisWorkbook.FollowHyperlink "C:\Program Files\Acute Data_1000.xlsx
 
Last edited:
Upvote 0
The code works for me when I use a valid path and filename.

What's error message are you getting?
 
Upvote 0
You can't add a hyperlink to a message box.

What you could do though is have the code hyperlink to the report, perhaps when the user clicks Yes in the message box.
Code:
Sub Report()
Dim Resp As VbMsgBoxResult

    Resp = MsgBox("Report is ready to use. Do you want to view it?", vbInformation + vbYesNo, "Report ready")


    If Resp = vbYes Then
        ThisWorkbook.FollowHyperlink "C:\Program Files\Acute Data_1000.xlsx"
    End If
    
End Sub

an alternative is
Code:
Sub Report()

    If MsgBox("Report is ready to use. Do you want to view it?", vbInformation + vbYesNo, "Report ready") = vbYes Then
        ThisWorkbook.FollowHyperlink environ("UserProfile") & "Documents\Acute Data_1000.xlsx"
    End If
    
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,563
Messages
6,120,248
Members
448,952
Latest member
kjurney

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top