How to VBA callback function when XMLHTTP onTimeOut?

后端 未结 2 944
谎友^
谎友^ 2021-01-05 05:23

I\'m trying get xml data from webserver to excel, then I wrote a sendRequest function to call in excel

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

2条回答
  •  礼貌的吻别
    2021-01-05 06:10

    The line;

    XMLHTTP.OnTimeOut = OnTimeOutMessage

    Is not a method assignment; rather it immediately executes OnTimeOutMessage() (and assigns its useless return value to OnTimeOut).

    The equivalent line in JavaScript as per your example link correctly assigns a Function object to OnTimeOut for subsequent invokation - this is not supported by VBA.

    Instead, you could trap the timeout error raised after .send or use early binding, WithEvents, & inline event handlers.

提交回复
热议问题