I have generated this as a new thread with the same title, as, apparently, I have not met the forum guidelines in the previous thread.
I am looking for a way to check all the hyperlinks within a workbook. I have several files containing hundreds of hyperlinks to networked files. As the network is accessed by many people, and there are no protocols controlling the movement, I find some of the hyperlinks no longer work because the files are no longer in the hyperlinked location.
In the previous thread the following was posted:
sub snb()
on error resume next
for each hp in sheets(1).hyperlinks
thisworkbook.followhyperlink hp.address
if err.number<>0 then hp.Range.Interior.ColorIndex = 3
err.clear
next
end sub
This works fine but opens each hyperlink in turn, meaning the PC grinds to a halt through lack of resources.
To overcome this issue the following was posted:
Sub snb()
On Error Resume Next
With New XMLHTTPRequest
For Each hp In Sheets(1).Hyperlinks
.Open "get", hp.Address
.send
If Err.Number <> 0 Then hp.Range.Interior.ColorIndex = 3
Err.Clear
Next
End With
End Sub
This overcomes the problem of opening each hyperlink, but gives an error error code value of '-2147467259' for all files, meaning each hyperlink cell turns red. Note the same files do not show an error in the first code.
I have tried adding a 10 second delay after the '.send' line in case the error is caused by a process timeout, as the files are on our (slow) network. The delay works but the error still exists. The 'Err.Clear' is changing the value to '0' as expected, so the error must be generated within the code.
Does anyone know where I can find out what the error value relates to and better still, how to eradicate it.
How can I modify this code so I do not get an error for each hyperlink?
Bookmarks