Detect broken url image links & fix easily

Hi Stephen

Found a little bit of visual basic code which can be installed onto any spreadsheet which will line by line check whether a url is valid or not, and simply returns either a “200” code if good OR or a “404” not found code if invalid. (haven’t had any other codes but these 2)

Works a treat for what I wanted because I can then sort the sheet by these results and check the ones that are corrupted or missing an image.

For my purposes it’s ideal.

And its very cheap code wise :slight_smile:

save the export file first as an xlsx file

remove the rubbish at the start i.e <img src="

and at the end " />

should have a straight text string remaining

go developer - sheet - insert - module

Public Function CheckURL(url As String)
Dim request As Object
Set request = CreateObject(“WinHttp.WinHttpRequest.5.1”)
On Error GoTo haveError
With request
.Open “HEAD”, url
.Send
CheckURL = .Status
End With
Exit Function
haveError:
CheckURL = Err.Description
End Function

save the sheet

in a new row enter
=CHECKURL(CELL NO)

Thanks for your suggestions

Ray