问题
In my spreadsheet I have a reference to the MS XML v3 library.
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"
Is it actually possible to pass a function into onreadystatechange
here? Can I pass a function "pointer" around in excel vba?
回答1:
Here's an approach to this type of task:
http://www.dailydoseofexcel.com/archives/2006/10/09/async-xmlhttp-calls/
来源:https://stackoverflow.com/questions/9866930/can-i-do-an-async-xml-call-in-excel-2010-vba