Hi All,
I have spent some time looking for code that will check a list of URLs and return 'OK' if they load successfully and 'FAILED' if not. The code below does that but there does not seem to be a way to test the Hyperlink.SubAddress (the position to go to on the web page) which some URLs have, as in the example below: #Usethecalc The code simply ignores the SubAddress, no matter what it is (all characters to the right of a hash symbol) and just checks the Hyperlink.Address itself.
Thanks kindly
Deutz
I have spent some time looking for code that will check a list of URLs and return 'OK' if they load successfully and 'FAILED' if not. The code below does that but there does not seem to be a way to test the Hyperlink.SubAddress (the position to go to on the web page) which some URLs have, as in the example below: #Usethecalc The code simply ignores the SubAddress, no matter what it is (all characters to the right of a hash symbol) and just checks the Hyperlink.Address itself.
VBA Code:
Sub TestURLs()
Dim strURL As String
Dim oURL As Object
Dim blnTest As Boolean
strURL = "https://www.ato.gov.au/calculators-and-tools/simple-tax-calculator/?=top_10_calculators#Usethecalc"
Set oURL = CreateObject("MSXML2.XMLHTTP")
With oURL
.Open "HEAD", strURL, False
.Send
blnTest = .Status = 200
If blnTest = False Then
Debug.Print strURL & " FAILED"
Else
Debug.Print strURL & " OK"
End If
Set oURL = Nothing
End With
End Sub
Thanks kindly
Deutz