Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default FollowHyperlink automatically


I have seen that it is possible, with Visual Basic, to conditionally
follow a hyperlink.

How should the code be if, f.e. at A5=100 (sum of other cells),
automatically a hyperlink is followed? In my case a music fragment
should be played.

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
????
????
????
????
End Sub

What comes in the place of the questionmarks to get this function
active?

Thanks.
Regards, Pieter-Jan


--
Pieter-Jan
------------------------------------------------------------------------
Pieter-Jan's Profile: http://www.excelforum.com/member.php...o&userid=27954
View this thread: http://www.excelforum.com/showthread...hreadid=474567

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default FollowHyperlink automatically

I'm not sure if this is what you're after, but rather than trying to do this
through the Worksheet_FollowHyperlink event, you can place the following code
in the macro of your choice (in your case, perhaps in the Worksheet_Change
event when the value of a certain cell meets a certain condition) to
hyperlink to the desired file or website
whenever the macro is run:

ThisWorkbook.FollowHyperlink "AddressToHyperlinkTo", , True

e.g.:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Address = "$A$5" Then
If Target.Value = 100 Then
ThisWorkbook.FollowHyperlink "C:\MusicFragment.mp3", , True
End If
End If
End Sub

HTH,
Dave

"Pieter-Jan" wrote:


I have seen that it is possible, with Visual Basic, to conditionally
follow a hyperlink.

How should the code be if, f.e. at A5=100 (sum of other cells),
automatically a hyperlink is followed? In my case a music fragment
should be played.

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
????
????
????
????
End Sub

What comes in the place of the questionmarks to get this function
active?

Thanks.
Regards, Pieter-Jan


--
Pieter-Jan
------------------------------------------------------------------------
Pieter-Jan's Profile: http://www.excelforum.com/member.php...o&userid=27954
View this thread: http://www.excelforum.com/showthread...hreadid=474567


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default FollowHyperlink automatically


Dave,

This is looking good to start with. Only one problem, the music is
playing when I type "100" in "A5", but not when 100 is calculated in
"A5". Can you solve this problem, or do I make a mistake?

Regards,
Pieter-Jan


--
Pieter-Jan
------------------------------------------------------------------------
Pieter-Jan's Profile: http://www.excelforum.com/member.php...o&userid=27954
View this thread: http://www.excelforum.com/showthread...hreadid=474567

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default FollowHyperlink automatically

Pieter Jan,
Try pasting this code at the top of your sheet's code:

Option Explicit
Private intCounter As Integer

Private Sub Worksheet_Calculate()
On Error Resume Next
Static varVal As Variant
With Range("A5")
If .Value = 100 And (.Value < varVal Or intCounter = 0) Then
ThisWorkbook.FollowHyperlink "C:\MusicFragment.mp3", , True
varVal = .Value
End If
End With
varVal = Range("A5").Value
intCounter = intCounter + 1
End Sub

You'll just need to change the name and path of the music file
HTH,
Dave

"Pieter-Jan" wrote:


Dave,

This is looking good to start with. Only one problem, the music is
playing when I type "100" in "A5", but not when 100 is calculated in
"A5". Can you solve this problem, or do I make a mistake?

Regards,
Pieter-Jan


--
Pieter-Jan
------------------------------------------------------------------------
Pieter-Jan's Profile: http://www.excelforum.com/member.php...o&userid=27954
View this thread: http://www.excelforum.com/showthread...hreadid=474567


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default FollowHyperlink automatically


Hi Dave,

It's working great now!
Thank you very much.

Best regards,
Pieter-Jan :

--
Pieter-Ja
-----------------------------------------------------------------------
Pieter-Jan's Profile: http://www.excelforum.com/member.php...fo&userid=2795
View this thread: http://www.excelforum.com/showthread.php?threadid=47456

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
FollowHyperlink Method Keith Excel Programming 0 June 6th 05 03:53 PM
FollowHyperlink to OLEObject Tony Excel Programming 0 January 5th 05 10:15 PM
FollowHyperlink Mike Archer[_3_] Excel Programming 0 December 19th 03 12:26 PM
followhyperlink Mike Archer[_2_] Excel Programming 0 December 18th 03 03:19 PM
followhyperlink failure Ron Dahl Excel Programming 2 November 4th 03 02:51 PM


All times are GMT +1. The time now is 09:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"