我正在尝试使用 Excel 2010 中的宏更新 Sharepoint 列表。到目前为止,我在更新常规文本或数字字段时没有遇到任何问题,但是在查找字段时,它会返回错误 0x80002005。我猜您不能简单地使用列表中的现有文字,但在我的一生中无法找到有关适当语法的任何文档。
这是我的 VBA 代码。
Set ObjHTTP = New MSXML2.XMLHTTP
sURL = "http://SITE_NAME_HERE_vti_bin/lists.asmx?op=UpdateListItems"
sEnv = "<?xml version=""1.0"" encoding=""utf-8""?>"
sEnv = sEnv & " <soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" "
sEnv = sEnv & " xmlns:xsd=""http://www.w3.org/2001/XMLSchema"""
sEnv = sEnv & " xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
sEnv = sEnv & " <soap:Body>"
sEnv = sEnv & " <UpdateListItems xmlns=""http://schemas.microsoft.com/sharepoint/soap/"">"
sEnv = sEnv & " <listName>MYLISTNAME</listName>"
sEnv = sEnv & " <updates>"
sEnv = sEnv & " <Batch OnError=""Continue"" ListVersion=""1"">"
sEnv = sEnv & " <Method ID=""1"" Cmd=""New"">\"
sEnv = sEnv & " <Field Name=""MYLOOKUPFIELD"">"
sEnv = sEnv & ""
sEnv = sEnv & " </Field>"
sEnv = sEnv & " </Method>"
sEnv = sEnv & " </Batch>"
sEnv = sEnv & " </updates>"
sEnv = sEnv & " </UpdateListItems>"
sEnv = sEnv & " </soap:Body>"
sEnv = sEnv & " </soap:Envelope>"
MsgBox (sEnv)
ObjHTTP.Open "Post", sURL, True
ObjHTTP.setRequestHeader "Content-Type", "text/xml"
ObjHTTP.setRequestHeader "dataType", " xml"
ObjHTTP.setRequestHeader "SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems"
ObjHTTP.send (sEnv)
Application.Wait (Now + TimeValue("0:00:10"))
MsgBox (ObjHTTP.responseText)
Set ObjHTTP = Nothing
Set xmlDoc = Nothing