我正在尝试使用 VBA 将项目添加到 Sharepoint 列表。我不希望用户必须安装任何东西,所以我只是使用 Microsoft Soap 类型库。代码如下:
Sub test()
Dim soap As MSSOAPLib.SoapClient
Dim XMLstr As String
Dim listid As String
Dim listname As String
Set soap = New SoapClient
Call soap.mssoapinit(bstrwsdlfile:="http://wss/mySharepointSite/_vti_bin/lists.asmx?wsdl")
listid = "{e285aa1a-my-list-ID-d446cdbf091e}"
listname = "thisList"
XMLstr = "<Method ID='1' Cmd='New'>" & _
"<Field Name='ID'>New</Field>" & _
"<Field Name='personID'>1337</Field>" & _
"</Method>"
soap.UpdateListItems listid, XMLstr
End Sub
soap.UpdateListItems
无论我是使用listid
还是listname
作为第一个参数,我都会在线上收到“类型不匹配”错误。我尝试阅读 WSDL 以确定应该传递哪种类型的参数,但我不明白。我应该在这里经过什么?
编辑:我通过使用 Microsoft Soap Type Library 3.0 来实现它,改变MSSOAPLib.SoapClient
->MSSOAPLib30.SoapClient30
和bstrwsdlfile
-> par_wsdlfile
,并围绕XMLstr
:
<Batch OnError='continue' ListVersion='1' ViewName='" & ListView & "'>
...
</Batch>
仍在尝试找出一种无需用户安装 MSSoap 3.0 的方法。