ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Testing Hyperlinks (https://www.excelbanter.com/excel-programming/378024-testing-hyperlinks.html)

DDawson

Testing Hyperlinks
 
Does anyone know of a way to test that hyperlinks are working/ not broken?

Regards
Dylan Dawson
Scotland

Steve Yandl

Testing Hyperlinks
 
Dylan,

Try something like what I have below. Hyperlinks reported as possibly
problematic should be tested manually since the subroutine will identify
things like a page that redirects as not being OK.

Sub TestHyperlinks()

Set objHTTP = CreateObject("MSXML2.XMLHTTP")

On Error Resume Next
For Each aLink In Cells.Hyperlinks
strURL = aLink.Address
objHTTP.Open "GET", strURL, False
objHTTP.Send
If objHTTP.statusText < "OK" Then
MsgBox "Possible problem with " & strURL
End If
Next aLink

Set objHTTP = Nothing
End Sub


Steve


"DDawson" wrote in message
...
Does anyone know of a way to test that hyperlinks are working/ not broken?

Regards
Dylan Dawson
Scotland




DDawson

Testing Hyperlinks
 
Thanks for helping me with this

"Steve Yandl" wrote:

Dylan,

Try something like what I have below. Hyperlinks reported as possibly
problematic should be tested manually since the subroutine will identify
things like a page that redirects as not being OK.

Sub TestHyperlinks()

Set objHTTP = CreateObject("MSXML2.XMLHTTP")

On Error Resume Next
For Each aLink In Cells.Hyperlinks
strURL = aLink.Address
objHTTP.Open "GET", strURL, False
objHTTP.Send
If objHTTP.statusText < "OK" Then
MsgBox "Possible problem with " & strURL
End If
Next aLink

Set objHTTP = Nothing
End Sub


Steve


"DDawson" wrote in message
...
Does anyone know of a way to test that hyperlinks are working/ not broken?

Regards
Dylan Dawson
Scotland






All times are GMT +1. The time now is 02:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com