Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Worksheet_FollowHyperlink does not fire if Hyperlink is invalid

Hi,

I have some Cells with Hyperlinks to Word-Documents, but sometimes the
Document doesn't exist. If I click on such a Link I'm getting a message like
"Could not open file..."

Now I want to catch this error using the Worksheet_FollowHyperlink-Event.
But it doesn't fire if the Link is invalid.

Any ideas?

Regards,

billy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Worksheet_FollowHyperlink does not fire if Hyperlink is invalid

I created this very basic follow followhyperlink procedure and even if the
links didn't open, they did put something in the immediate window.

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Dim myCell As Excel.Range

Set myCell = Target.Parent
Debug.Print myCell.Address, myCell.Value

End Sub

It sounds like you are opening files with your hyperlinks. You may want to
consider using the 'FileExists' method described here.

http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx

I prefer something that returns a boolean variable and may have found this
somewhere, but this is what I use.

Function myFileExists(myPath As String) As Boolean
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(myPath) Then
myFileExists = True
'no problem
Else
myFileExists = False
End If

Set FSO = Nothing
End Function

HTH,
Barb Reinhardt

"Billy" wrote:

Hi,

I have some Cells with Hyperlinks to Word-Documents, but sometimes the
Document doesn't exist. If I click on such a Link I'm getting a message like
"Could not open file..."

Now I want to catch this error using the Worksheet_FollowHyperlink-Event.
But it doesn't fire if the Link is invalid.

Any ideas?

Regards,

billy

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Worksheet_FollowHyperlink does not fire if Hyperlink is invali

Hi Barb,

I created this very basic follow followhyperlink procedure and even if the
links didn't open, they did put something in the immediate window.


hmm, not in my example. Which version of Excel are you using?
My is 2003 - I think this is from Office XP.

It sounds like you are opening files with your hyperlinks. You may want
to consider using the 'FileExists' method described here.


that's what I wanted to do in my exception handler - but as I've written, it
does not fire if eg. the file was renamed after the hyperlink has been
created :-(

Regards,

billy



"Barb Reinhardt" wrote:

I created this very basic follow followhyperlink procedure and even if the
links didn't open, they did put something in the immediate window.

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Dim myCell As Excel.Range

Set myCell = Target.Parent
Debug.Print myCell.Address, myCell.Value

End Sub

It sounds like you are opening files with your hyperlinks. You may want to
consider using the 'FileExists' method described here.

http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx

I prefer something that returns a boolean variable and may have found this
somewhere, but this is what I use.

Function myFileExists(myPath As String) As Boolean
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(myPath) Then
myFileExists = True
'no problem
Else
myFileExists = False
End If

Set FSO = Nothing
End Function

HTH,
Barb Reinhardt

"Billy" wrote:

Hi,

I have some Cells with Hyperlinks to Word-Documents, but sometimes the
Document doesn't exist. If I click on such a Link I'm getting a message like
"Could not open file..."

Now I want to catch this error using the Worksheet_FollowHyperlink-Event.
But it doesn't fire if the Link is invalid.

Any ideas?

Regards,

billy

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
event fire Curt Excel Programming 19 March 7th 07 12:29 AM
I need to repair an invalid hyperlink S. Banks - Admin. Asst. Excel Worksheet Functions 1 October 23rd 06 03:08 PM
Code will not fire Ray A Excel Programming 5 March 1st 06 05:41 PM
Worksheet_FollowHyperlink NamssoB Excel Programming 1 August 31st 05 02:19 PM
call a sub with arguments from Worksheet_FollowHyperlink event Tom Ogilvy Excel Programming 5 August 28th 03 10:58 PM


All times are GMT +1. The time now is 10:49 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"