It has happened that the server hangs or that there is something wrong with the http request I am sending. So I was wondering if I could add a timeout code to my function to avoid my macro from crashing, but rather return an empty array and then I can use that to display an error message to the user...
Function helpRequest(stringQuery As String) As String()
Dim objRequest As MSXML2.XMLHTTP60
Dim O As MSHTML.HTMLDocument
Dim i As Integer
Dim asCells() As String
Dim contentType As String
Dim temp As String
If UCase(Right(stringQuery, 4)) = ".ASP" Then
stringQuery = stringQuery & "?Cache=" & CStr(Int(200000000000000# * Rnd))
Else
stringQuery = stringQuery & "&Cache=" & CStr(Int(200000000000000# * Rnd))
End If
contentType = "application/x-www-form-urlencoded; charset=UTF-8"
Set O = New HTMLDocument
Set objRequest = CreateObject("MSXML2.XMLHTTP.6.0")
With objRequest
.Open "GET", stringQuery, False
.send
End With
O.body.innerHTML = objRequest.responseText
.readyState.