2015-02-24 105 views
5

是否可以将超链接添加到消息框?我试图做这样的事情:在消息框中放置超链接

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 _ 
     & "For CSC self-help instructions on how to reload the most current version of the PRF Intake Tool to your computer, please click the link below to be directed to CSC Online instructions." & vbCr _ 
     & vbCr _ 
     & "http://www.OurSite.com/online/Solutions/Search_Results.asp?opsystem=7&keywords=PRF+Intake+Tool&Category=", , "There is a problem..." 

问题是,超链接是不可点击的。我想这样做,以便用户只需点击链接并自动开始下载。

我在Win7环境中使用Access 2010。

+0

没有,但你可以询问用户是否他们想打开链接然后将IE导航到该位置。 – Gareth 2015-02-24 20:50:45

+3

或为消息框构建自定义窗体,然后您可以在超链接中添加 – Sorceri 2015-02-24 20:52:18

回答

7

一个简单的答案是。 MsgBox不允许超链接,只是纯文本。

因此,这是一个解决方法,应该可以正常工作。

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 

如果下划线的风格是必须的,那么你应该就像在http://j-walk.com/ss/excel/tips/tip71.htm描述创建自己的用户表单。以下是具体步骤:

  1. 添加Label对象,然后输入短信
  2. 使标签蓝色(ForeColor)和下划线(Font),所以它看起来像一个典型的超链接。
  3. 设置标签的MousePointer属性99 - fmMousePointerCustom
  4. 指定标签的MouseIcon图像光标文件(如果有的话)。
  5. 双击该标签并创建子程序单击事件。下面是一个示例代码:

    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 
    

要创建“邮件”超链接,请使用如下语句:

Link = "mailto:[email protected]" 
+1

谢谢!这很好。 – 2015-02-25 02:49:15

+0

这解决了一个完全不相关的问题,我.... ....谢谢 – 2017-10-04 22:28:23