hyperlink prompt
Hi there,
Does anyone know if it's possible to prompt (Do you want to go to this link, Yes No) before following a hyperlink? Many thanks in advance. |
hyperlink prompt
Save we have Inserted a hyperlink in cell B2. (we can't use the =HYPERLINK()
function here.) Install the following event macro in the worksheet code area: Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) If Target.Range.Address = "$B$2" Then If Application.InputBox(prompt:="Are you sure you want to leave me??", Type:=2) = "no" Then Application.Goto End If End If End Sub If we type "no" we are back to B2, otherwise at are at the hyperlink destination. -- Gary''s Student - gsnu200851 "Libby" wrote: Hi there, Does anyone know if it's possible to prompt (Do you want to go to this link, Yes No) before following a hyperlink? Many thanks in advance. |
hyperlink prompt
I think I'd tweak your code like this (because people like to enter Y or N or
YES or NO or some other upper/lower case version of Y or N. Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) Dim Verify as VbMsgBoxResult If Target.Range.Address = "$B$2" Then Verify = Msgbox("Are you sure you wnat to leave me?",vbYesNo) If Verify = VBNo Then Application.Goto End If End If End Sub "Gary''s Student" wrote: Save we have Inserted a hyperlink in cell B2. (we can't use the =HYPERLINK() function here.) Install the following event macro in the worksheet code area: Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) If Target.Range.Address = "$B$2" Then If Application.InputBox(prompt:="Are you sure you want to leave me??", Type:=2) = "no" Then Application.Goto End If End If End Sub If we type "no" we are back to B2, otherwise at are at the hyperlink destination. -- Gary''s Student - gsnu200851 "Libby" wrote: Hi there, Does anyone know if it's possible to prompt (Do you want to go to this link, Yes No) before following a hyperlink? Many thanks in advance. |
hyperlink prompt
Thanks for your comments. However the link is to an external file and when I
run the code it executes after the file has been opened. "Barb Reinhardt" wrote: I think I'd tweak your code like this (because people like to enter Y or N or YES or NO or some other upper/lower case version of Y or N. Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) Dim Verify as VbMsgBoxResult If Target.Range.Address = "$B$2" Then Verify = Msgbox("Are you sure you wnat to leave me?",vbYesNo) If Verify = VBNo Then Application.Goto End If End If End Sub "Gary''s Student" wrote: Save we have Inserted a hyperlink in cell B2. (we can't use the =HYPERLINK() function here.) Install the following event macro in the worksheet code area: Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) If Target.Range.Address = "$B$2" Then If Application.InputBox(prompt:="Are you sure you want to leave me??", Type:=2) = "no" Then Application.Goto End If End If End Sub If we type "no" we are back to B2, otherwise at are at the hyperlink destination. -- Gary''s Student - gsnu200851 "Libby" wrote: Hi there, Does anyone know if it's possible to prompt (Do you want to go to this link, Yes No) before following a hyperlink? Many thanks in advance. |
hyperlink prompt
Just to say that I've found how to do it at this site:
http://www.ozgrid.com/forum/showthread.php?t=78124 It works well, but relies on the hyperlink being created with no address, a sub address of the cell it's in and the path you really want to follow in the screen tip. "Libby" wrote: Thanks for your comments. However the link is to an external file and when I run the code it executes after the file has been opened. "Barb Reinhardt" wrote: I think I'd tweak your code like this (because people like to enter Y or N or YES or NO or some other upper/lower case version of Y or N. Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) Dim Verify as VbMsgBoxResult If Target.Range.Address = "$B$2" Then Verify = Msgbox("Are you sure you wnat to leave me?",vbYesNo) If Verify = VBNo Then Application.Goto End If End If End Sub "Gary''s Student" wrote: Save we have Inserted a hyperlink in cell B2. (we can't use the =HYPERLINK() function here.) Install the following event macro in the worksheet code area: Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) If Target.Range.Address = "$B$2" Then If Application.InputBox(prompt:="Are you sure you want to leave me??", Type:=2) = "no" Then Application.Goto End If End If End Sub If we type "no" we are back to B2, otherwise at are at the hyperlink destination. -- Gary''s Student - gsnu200851 "Libby" wrote: Hi there, Does anyone know if it's possible to prompt (Do you want to go to this link, Yes No) before following a hyperlink? Many thanks in advance. |
All times are GMT +1. The time now is 10:45 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com