excel - How to VBA callback function when XMLHTTP onTimeOut? -


I'm webserver try to get to the XML data to excel, so I have a sendRequest

= sendRequest ("http://abb.com/index.php?id=111")

The problem with web-server, can not connect or can not be found, is not giving excellent answer, it was terrible! To avoid this, I think that should set us time these are my function:

  function sendRequest (URL) Call Set XMLHTTP = CreateObject ( "Msxml2.ServerXMLHTTP.6.0 ") are received 'the timeout value in seconds lResolve = 10 * 1000 lConnect = 10 * 1000 lSend = 10 * 1000 lReceive = 15 * 1000 callback function XMLHTTP.Open" gET "', lReceive XMLHTTP.OnTimeOut = OnTimeOutMessage server XMLHTTP. setTimeOuts lResolve, lConnect, waiting time to obtain data from lSend ', url, false error resume Next error XMLHTTP.Send Oto 0 sendRequest = (XMLHTTP.responseText) End Function Private Function OnTimeOutMessage () 'Application.Caller.Value = "Server Error: Request timed out" MsgBox ( "Server Error: Request time out") End Function   

usually happens when XMLHTTP end time, the event OnTimeOutMessage will be executed (reference). But As such, OnTimeOutMessage is performed at the beginning of the sendRequest ()

How to use the callback function when Msxml2 .ServerXMLHTTP.6.0 Is Request Timeout?

Thank you for your help!

line;

XMLHTTP.OnTimeOut = OnTimeOutMessage

There is no method assignment; But it gives immediate OnTimeOutMessage () performs (and its waste return value OnTimeOut .

JavaScript according to your example links, provides the perfect way for a function object invitation in the Ontaimot after - it is not supported by VBA. < P> Instead, you can go to the trap after the timeout error has been raised or the initial binding, after the .seend Nts , & amp; inline event handlers.

Comments