Jack
Jack

Reputation: 497

HTTP request freezes when I run the program, but not when I step in

the program runs from an excel workbook,takes a list of values, builds a query string and passes it to this chunk of code

Set xmlHttp = CreateObject("MSXML2.XMLHTTP.6.0")
xmlHttp.Open "GET", connectionstring, False
xmlHttp.setRequestHeader "Content-Type", "text/xml"
xmlHttp.send

Dim html As Object
Set html = CreateObject("htmlfile")
html.body.innerHTML = xmlHttp.ResponseText

This is part of a loop, so it gets executed many times. If I step into the code and execute it line by line there is no problem, but when I run it it freezes on the xmlHttp.send line, not at the first loop, but somewhere in the middle of the loop (around the 10th execution maybe). Do I have to tell it to wait for soething in particular? Any Ideas? Thanks

Upvotes: 3

Views: 1457

Answers (1)

R3uK
R3uK

Reputation: 14537

XMLHTTP has a ReadyState property like IE :

So this is how to use it :

xmlHttp.send
Do While xmlHttp.readyState <> 4
    DoEvents
Loop

Upvotes: 3

Related Questions