J
Joel Wiseheart
Is it possible to put a hyperlink in a MsgBox function
text?
text?
Joel Wiseheart said:Is it possible to put a hyperlink in a MsgBox function
text?
' UFHyperlink form by Big Cnut
' Displays a message box like form with a clickable link
' Usage: UFHyperlink.HLinkMsgBox "Click on the link below to open it:", "HLinksMsgBox Test", "C:\Temp"
Private HLinkOpenCmd As String ' The command to use for opening the hyperlink
Private Sub BtnClose_Click()
Hide
End Sub
Private Sub LHyperlink_Click()
Shell HLinkOpenCmd & LHyperlink.Caption, vbNormalFocus ' Open the link
Hide
End Sub
Private Sub UserForm_Initialize()
LHyperlink.Font.Underline = True ' Make it look like a link
End Sub
Public Sub HLinkMsgBox(Prompt As String, Title As String, Hyperlink As String, Optional OpenCmd As String = "Explorer.exe /select, ")
HLinkOpenCmd = OpenCmd ' Set the command for opening the hyperlink
With UFHyperlink
.Caption = Title ' Set the window's title
' Set the prompt
With .LPrompt
.Caption = Prompt ' Set the width in order to use the whole form's width (as setting the caption resized the label)
.Width = UFHyperlink.Width - 17.25
' Now trigger a vertical resize
.AutoSize = False
.AutoSize = True
End With
' Set the hyperlink
With .LHyperlink
.Caption = Hyperlink
.Top = UFHyperlink.LPrompt.Top + UFHyperlink.LPrompt.Height + 4 ' Adjust the vertical position depending on the height of the prompt
.Width = UFHyperlink.Width - 17.25 ' Set the width in order to use the whole form's width (as setting the caption resized the label)
' Now trigger a vertical resize
.AutoSize = False
.AutoSize = True
End With
.BtnClose.Top = .LHyperlink.Top + .LHyperlink.Height + 10 ' Adjust the vertical position of the close button
.Height = .BtnClose.Top + .BtnClose.Height + 30 ' Adjust the form's height
.Show ' Display the form
End With
End Sub
Sub TESTHLinkMsgBox()
UFHyperlink.HLinkMsgBox "Click on the link below to open it:", "HLinksMsgBox Test", "C:\Temp"
End Sub