Bonjour à tous,
Voila je fait au travers du VBA des requêtes HTTP pour récupérer dans les cellules excel des informations d'équipements distants.
Le problème est que quand un équipement n'est pas joignable, il le code ne passe pas au suivant et j'ai la fenêtre "erreur d'execution '-2147012894' : le délai imparti à l'opération est dépassé" qui s'ouvre.
Quelqu'un aurait une astuce ?
Voici mon code :
Dim wq As WinHttp.WinHttpRequest
Sub RequeteHTTP()
Dim strURL As String, strResp As String
Dim i, j As Integer
Const HTTPREQUEST_SETCREDENTIALS_FOR_SERVER As Long = 0
Const HTTPREQUEST_SETCREDENTIALS_FOR_PROXY As Long = 1
Range("D3:BE7397").ClearContents
j = WorksheetFunction.CountA(Range("a:a"))
For i = 3 To j
strURL = "http://" & Range("A" & i).Value
strURL = strURL & "/rcgi.bin/ParamForm?AST_Param=$$dtSE$se" & Range("D2").Value & "@"
On Error GoTo ERRH
Set wq = New WinHttpRequest
' Création requêtte HTTP de type GET
wq.Open "GET", strURL
wq.SetCredentials Range("B" & i).Value, Range("C" & i).Value, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
' Envoie de la requête
wq.Send
If wq.Status = 200 Then
' Récupérer le corps de la réponse
strResp = wq.ResponseText
' exploitation de la réponse
Range("D" & i).Value = strResp
Else
Range("D" & i).Value = wq.Status & " " & wq.StatusText & " " & "Statut renvoyé par serveur"
End If
BOUCLE:
Next i
GoTo ENDPROC
ERRH:
'MsgBox ERR.Description
Range("D" & i).Value = "Erreur No." & Err.Number & " : " & Err.Description
GoTo BOUCLE
ENDPROC:
Set wq = Nothing
End Sub