[英]Can I do an async XML call in Excel 2010 VBA?
In my spreadsheet I have a reference to the MS XML v3 library. 在我的电子表格中,我引用了MS XML v3库。
Here is my sample code 这是我的示例代码
Option Explicit
Private objConn As XMLHTTP30
Public Sub HandleAsyncEvent()
Debug.Print "Done"
End Sub
Public Function InitService(serviceUrl As String, Optional asyncMode As Boolean = True)
Set objConn = New XMLHTTP30
objConn.Open "POST", serviceUrl, asyncMode
objConn.setRequestHeader "Content-Type", "text/xml"
objConn.onreadystatechange = HandleAsyncEvent
End Function
I encountered a runtime exception when it comes to the line 当涉及到这一行时,我遇到了运行时异常
objConn.onreadystatechange = HandleAsyncEvent
Excel throws the exception "Object required" Excel抛出异常“对象必需”
Is it actually possible to pass a function into onreadystatechange
here? 实际上是否可以将函数传递给
onreadystatechange
? Can I pass a function "pointer" around in excel vba? 我可以在excel vba中传递函数“指针”吗?
Here's an approach to this type of task: 以下是此类任务的方法:
http://www.dailydoseofexcel.com/archives/2006/10/09/async-xmlhttp-calls/ http://www.dailydoseofexcel.com/archives/2006/10/09/async-xmlhttp-calls/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.