Hi, does anyone have a code that can go through a list of hyperlinks and check if they can be opened or not? Some may be corrupt which is the reason they cannot be opened. This is what I have so far but the error command doesn't seem to work. The aim is to delete the hyperlinks that cannot be opened.
Code:
Sub testlinks()
On Error GoTo deleteit
Dim wbTarget As Workbook
Dim ary(3) As Variant
Dim lRow As Long
Dim CodeNames As Variant, i As Long
CodeNames = Range("Z2:Z" & Cells(Rows.Count, "Z").End(xlUp).Row)
For i = 1 To UBound(CodeNames, 1)
If InStr(1, CodeNames(i, 1), ".xls") > 0 Then
Set wbTarget = Workbooks.Open(CodeNames(i, 1))
wbTarget.Close SaveChanges:=False
GoTo endit
End If
deleteit:
CodeName = ""
endit:
Next i
Set wbTarget = Nothing
End Sub