Putting a hyperlink in a MessageBox

前端 未结 1 860
清酒与你
清酒与你 2020-12-17 23:18

Is it possible to add a hyperlink to a messagebox? I\'m trying to do something like this:

   MsgBox \"Sorry, but you have an out-of-date database version.           


        
相关标签:
1条回答
  • 2020-12-17 23:26

    A straight-forward answer is NO. MsgBox does not allow hyperlinks, just plain text.

    Thus, here is a workaround that should work alright.

    Set objShell = CreateObject("Wscript.Shell")
    
    intMessage = MsgBox("Sorry, but you have an out-of-date database version.  Please redownload via the batch file to ensure that you have the latest version. Contact the administrator of this database or your manager if you need help." & vbCr _
            & vbCr _
            & "Your current database version is " & CurrentVer & " which may be out of date. The current database version prescribed on the network share is " & FileVer & ". They must match in order for you to proceed." & vbCr _
            & vbCr _
            & "Would you like to learn more about CSC self-help instructions on how to reload the most current version of the PRF Intake Tool to your computer?", _
            vbYesNo, "There is a problem...")
    
    If intMessage = vbYes Then
        objShell.Run ("http://www.OurSite.com/online/Solutions/Search_Results.asp?opsystem=7&keywords=PRF+Intake+Tool&Category=")
    Else
        Wscript.Quit
    End If
    

    If underline style is a requirement, then you should just create your own User Form as described at http://j-walk.com/ss/excel/tips/tip71.htm. Here are the steps:

    1. Add a Label object and type your message
    2. Make the Label blue (ForeColor) and underlined (Font) so it looks like a typical hyperlink.
    3. Set the Label's MousePointer property to 99 - fmMousePointerCustom
    4. Specify the cursor file for the Label's MouseIcon image (if you have one).
    5. Double-click the Label and create a subroutine the Click event. Here's a sample code:

      Private Sub Label1_Click()
        Link = "http://www.YOUR_SITE.com"
        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:someone@somewhere.com"
    
    0 讨论(0)
提交回复
热议问题