private sub worksheet_followhyperlink ...

mbt2103

New Member
Joined
Aug 4, 2014
Messages
35
My code:
Code:
Private Sub worksheet_followhyperlink(ByVal HL As Hyperlink)
Dim linkReq As Object
Dim linkStatus As Integer
Dim sourceCell As Range
Debug.Print HL.Address
Application.EnableEvents = False


linkStatus = 200
If Dir(HL.Address) = "" Then linkStatus = 404


If linkStatus = 404 Then HL.Parent.Offset(0, 21).Value = "N"
If linkStatus = 200 Then HL.Parent.Offset(0, 21).Value = "Y"


On Error Resume Next
If HL.Parent = "" Then
    HL.Parent.Hyperlinks.Delete
    GoTo exitSub
End If




exitSub:
Application.ScreenUpdating = True
Application.EnableEvents = True


End Sub

Works if the file is present, but doesn't even trigger if the file is absent.
Would love to capture the "Cannot open the specified file" alert and code it as data on my sheet, but I'm not sure how. I would also like to attempt to automatically correct broken links. Any thoughts on how to get this thing to fire?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,214,923
Messages
6,122,289
Members
449,077
Latest member
Rkmenon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top