#1   Report Post  
Posted to microsoft.public.excel.misc
bnbbond
 
Posts: n/a
Default Test a Hyperlink

I have a large file w/ Hyperlinks to various PDFs.
I am wanting to try and run a MACRO that will go through and
test to make sure all of the links work correctly.
Is there a way to do this?
Ben
  #2   Report Post  
Posted to microsoft.public.excel.misc
snicho
 
Posts: n/a
Default Test a Hyperlink

Ben, I had a similar requirement some months ago and came up with the
following.
Note that this is to test for hyperlinks to PDFs residing on the LAN you are
woking on. I have also found it necessary to set Files, Properties,
Hyplerlink Base to "\\" (without the inverted commas). This gets around
problems created when different users open the same file when they have a
different relative path for their logon.

Private Sub CheckAllPDFHyperlinks()
Dim test As Boolean
Dim count As Integer
Dim h As Hyperlink

count = 0

test = True
On Error GoTo OnError

For Each h In ActiveSheet.Hyperlinks
If InStr(UCase(h.Name), "PDF") 0 Then
If Dir(h.Address) = "" Then
test = False
MsgBox h.Name & vbCr & _
h.Address & vbCr & _
h.SubAddress & vbCr & _
"in cell " & h.Range.Address & vbCr & _
"link path does not exist"
response = MsgBox("Do you want to continue?", vbYesNo)
If response < vbYes Then
response = MsgBox("Do you want to goto this cell?", vbYesNo)
If response = vbYes Then
Range(h.Range.Address).Select
End If
Application.StatusBar = False
Exit Sub
End If
End If
End If
count = count + 1
Application.StatusBar = "Links checked: " & count
Next h
If test Then MsgBox count & " Hyperlinks checked ok."
Application.StatusBar = False
Exit Sub

OnError:
MsgBox ("Error with: " & h.Name & vbCr & "Unable to search this path.
Possible invalid characters or invalid syntax.")
response = MsgBox("Do you want to goto this cell?", vbYesNo)
If response = vbYes Then
Range(h.Range.Address).Select
End If
Application.StatusBar = False
End Sub

"bnbbond" wrote:

I have a large file w/ Hyperlinks to various PDFs.
I am wanting to try and run a MACRO that will go through and
test to make sure all of the links work correctly.
Is there a way to do this?
Ben

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
Hyperlink function fails when using variable row number Balex Excel Worksheet Functions 5 April 8th 06 06:35 AM
answer to odd results when comparing hyperlink addresses Patricia Shannon Links and Linking in Excel 0 March 9th 06 07:28 PM
Hyperlink won't open any other XLS file Jinx1966 Excel Discussion (Misc queries) 2 February 9th 06 08:26 AM
Using the Hyperlink Function and finding filenames Jeni Q Excel Worksheet Functions 0 September 20th 05 02:37 PM
Removing hyperlink Frank Marousek Excel Discussion (Misc queries) 3 January 12th 05 09:53 PM


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