我可以在Excel 2010 VBA中执行异步XML调用吗?

时间:2012-03-26 05:15:39

标签: excel excel-2010 msxml

在我的电子表格中,我引用了MS XML v3库。

这是我的示例代码

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

当涉及到行

时遇到了运行时异常
objConn.onreadystatechange = HandleAsyncEvent

Excel抛出异常“需要对象”

实际上是否可以将函数传递给onreadystatechange?我可以在excel vba中传递函数“指针”吗?

1 个答案:

答案 0 :(得分:2)