Trying to determine if a file exists on the server using an MSXML2.XMLHTTP request. It works most of the time but every once in a while fails with "Operation timed out". At most, there error condition kicks in once and theh it returns to working normally. Any ideas?
Public Function InputFileThere(myUrl As String) As Boolean
Dim myLine As String
Dim numTimes As Long
Dim MyRequest As Object
Dim urlExists As Boolean
numTimes = 0
urlExists = False
Dim dirName As String
Dim userName As String
Dim passWord As String
userName = “******”
passWord = “******”
On Error GoTo errorPart
startHere:
Set MyRequest = CreateObject("MSXML2.XMLHTTP")
MyRequest.Open "HEAD", myUrl, False, userName, passWord
MyRequest.send
If MyRequest.StatusText = "OK" Then urlExists = True
GoTo finHere
errorPart:
Set MyRequest = Nothing
numTimes = numTimes + 1
myLine = " Right now " & Format(Now(), "hh:mm:ss") & " there was an error , numTimes = " & CStr(numTimes) & " Err Description = " & Err.Description
Application.StatusBar = myLine
Application.Wait (Now() + TimeValue("00:01:00"))
GoTo startHere
finHere:
InputFileThere = urlExists
Set MyRequest = Nothing
End Function