我正在尝试使用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
答案 0 :(得分:3)
尝试运行GetListItems
,您会看到查找以ID in Source List;#Value in Source List
的编码格式存储其值。例如,ows_MyLookup="13;#MyValue"
。调用UpdateListItems
时,您需要以此格式传递值。