Thread: validate url
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
geebee geebee is offline
external usenet poster
 
Posts: 190
Default validate url

hi,

i have the following:

Function IsLink(url)
Dim http As Object
Dim xmlhttp As Object

Set http = CreateObject("MSXML2.ServerXMLHTTP.4.0")
Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")

On Error Resume Next



xmlhttp.Open "GET", url, False
'This alternative can return status 405 in some cases
'xmlhttp.Open "HEAD", url, False
xmlhttp.Send ""

'You can get the status of the page, if you wish
Status = xmlhttp.Status

If Err.Number < 0 Or Status < 200 Then
IsLink = False
Else
IsLink = True
End If

Set xmlhttp = Nothing

then i have:

Sub L()

IsLink ("HTTP://www.microsoft.com/en/us/default.aspx")

MsgBox Status

End Sub

am i doing something wrong? because i know the website exists, and it
should be returning TRUE.

thanks in advance,
geebee