在 MessageBox 中放置超链接 [英] Putting a hyperlink in a MessageBox

查看:128
本文介绍了在 MessageBox 中放置超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.  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..."

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

The problem is, the hyperlink isn't clickable. I'd like to do this so that the users can just click the link and have the download begin automatically.

我在 Win7 环境中使用 Access 2010.

I'm using Access 2010 in a Win7 environment.

推荐答案

一个直接的答案是.MsgBox 不允许超链接,只有纯文本.

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

如果下划线样式是必需的,那么您应该创建自己的用户表单,如http://j-walk.com/ss/excel/tips/tip71.htm.以下是步骤:

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. 添加一个 Label 对象并输入您的消息
  2. 将标签设为蓝色 (ForeColor) 并加下划线 (Font),使其看起来像一个典型的超链接.
  3. 将标签的 MousePointer 属性设置为 99 - fmMousePointerCustom
  4. 为标签的 MouseIcon 图像(如果有)指定光标文件.
  5. 双击标签并创建一个子例程 Click 事件.这是一个示例代码:

  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

要创建mail to"超链接,请使用如下语句:

To create a "mail to" hyperlink, use a statement like this:

Link = "mailto:someone@somewhere.com"

这篇关于在 MessageBox 中放置超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆