将超链接放入 MessageBox
Putting a hyperlink in a MessageBox
是否可以将 hyperlink 添加到消息框?我正在尝试做这样的事情:
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..."
问题是,hyperlink 不可点击。我想这样做,以便用户只需单击 link 即可自动开始下载。
我在 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
要创建 "mail to" 超链接,请使用如下语句:
Link = "mailto:someone@somewhere.com"
是否可以将 hyperlink 添加到消息框?我正在尝试做这样的事情:
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..."
问题是,hyperlink 不可点击。我想这样做,以便用户只需单击 link 即可自动开始下载。
我在 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
要创建 "mail to" 超链接,请使用如下语句:
Link = "mailto:someone@somewhere.com"