Thread: validate url
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default validate url

Remove the ON ERROR statement and try again. Your code is failing and you
don't know it.

"geebee" wrote:

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