Is there an easy way to test a hyperlink

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am looking for a quick way to programmatically check a hyperlink in a table
cell to make sure it links to a real file (i.e. - is not broken). Does
anyone have an idea of how this could be done?

Thanks for your help.
 
Jim said:
I am looking for a quick way to programmatically check a hyperlink in
a table cell to make sure it links to a real file (i.e. - is not
broken). Does anyone have an idea of how this could be done?

Thanks for your help.


try this:

Note, that several servers redirect requests, so it's not
possible to get the correct status.

'-------------------------------------------------------------
' Get the status of a Webpage
' Returns: String containing status# and status-text
'-------------------------------------------------------------
Public Function GetLinkStatus(ByVal sURL As String) As String

Dim xmlhttp As Object
Dim strStatus As String
Dim lngStatus As Long

If Not Left(sURL, 7) = "http://" Then
sURL = "http://" & sURL
End If

Set xmlhttp = CreateObject("Msxml2.XMLHTTP")

On Error Resume Next

xmlhttp.Open "GET", sURL, False
xmlhttp.send
lngStatus = xmlhttp.status
strStatus = xmlhttp.StatusText

Set xmlhttp = Nothing
On Error GoTo 0
GetLinkStatus = lngStatus & " - " & strStatus

End Function
 
Jim said:
I am looking for a quick way to programmatically check a hyperlink in
a table cell to make sure it links to a real file (i.e. - is not
broken). Does anyone have an idea of how this could be done?


hyperlink ...links to a real file

That should do the Dir() function.

Acki
 
Back
Top