vba - 将超链接放入MessageBox

标签 vba ms-access hyperlink ms-access-2010 messagebox

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

   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。

最佳答案

简单的答案是。 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所述创建自己的用户表单。步骤如下:
  • 添加一个Label对象并键入您的消息
  • 将标签设置为蓝色(ForeColor)和带下划线的(Font),使其看起来像典型的超链接。
  • 将Label的MousePointer属性设置为99-fmMousePointerCustom
  • 指定标签的MouseIcon图像的光标文件(如果有的话)。
  • 双击Label并创建一个子例程Click事件。这是一个示例代码:
    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:someone@somewhere.com"
    

    关于vba - 将超链接放入MessageBox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28705916/

    相关文章:

    Angularjs 指令使任何元素像链接一样工作

    arrays - VBA 中的属性数组

    VBA 错误 424,使用 ".Value"属性将值写入单元格

    ms-access - 使用存储过程的查询表达式中的语法错误(缺少运算符)

    sql-server - 为少数用户应用程序选择合适的数据库

    api - 更改YouTube API生成的链接的行为

    ms-access - ms access - 基于文本框值的复选框

    mysql - SQL 迁移后 VBA 脚本不再工作

    ms-access - 如何刷新 WebBrowser 控制 MS Access

    hyperlink - Jsoup 获取页面中的所有链接