Sub test()
Dim id As String
id = "user1234"
Dim PHARMA As String
PHARMA = "http://xxxx"
Dim url As String
url = PHARMA & id
Dim IE As MSXML2.XMLHTTP60
Set IE = New MSXML2.XMLHTTP60
IE.Open "GET", url, False
IE.send
'This part could crash the program crash if the user
'or the url is wrong, how can I handle this case with exceptions?
While IE.readyState <> 4
DoEvents
Wend
Dim HTMLDoc As MSHTML.HTMLDocument
Dim HTMLBody As MSHTML.HTMLBody
Set HTMLDoc = New MSHTML.HTMLDocument
...
End Sub
Here the kind of anwser I put a wrong ID or url
When I go in chrome in the network tab :
Cache-Control:no-cache
Content-Length:0
Date:Tue, 25 Oct 2016 15:22:04 GMT
Expires:-1
Pragma:no-cache
Server:Microsoft-IIS/7.0
When I go in the answer tab I have :
the request has no response data available (normal because url or id is wrong)
How can I handle network exceptions in VBA ?