2015-05-26 57 views
0

我正在嘗試使用VBA和SOAP從共享點列表中提取特定數據點。不過,我對VBA和共享點都很陌生,所以有幾件事情對我來說沒有意義。目前,我試圖用這個網站作爲一個參考:使用SOAP檢索Sharepoint列表

http://depressedpress.com/2014/04/05/accessing-sharepoint-lists-with-visual-basic-for-applications/

我有問題試圖找到在哪裏可以找到SharePoint網站的憑證信息。我將在哪裏準確找到用戶名,密碼和SOAP URL?

回答

1

Chang -

我在VBA下面寫了一個簡單的SharePoint列表SOAP查詢。我能夠在Excel中運行它並從SharePoint中提取數據。

然而,幾乎沒有人使用VBA進行SOAP調用。通常使用JavaScript,C#或Java完成。此外,大多數人已經脫離了SOAP,現在正在使用SharePoint中提供的更新的REST服務。如果你的目標是學習,那麼REST可能會更好(也更容易)。下面是一些微軟的參考,讓你開始:

例:查詢的SharePoint的UserInfo表使用VBA

Sub spListQuery() 

    Dim webUrl, wsdl, action, soap, xhr As XMLHTTP60 

    itemId = 1 
    listName = "UserInfo" 
    webUrl = "http://youserver.com" 'set to SharePoint site url 
    wsdl = "/_vti_bin/Lists.asmx" 
    action = "http://schemas.microsoft.com/sharepoint/soap/GetListItems" 

soap = "<?xml version=""1.0"" encoding=""utf-8""?>" & _ 
"<soap:Envelope " & _ 
    "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" " & _ 
    "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" " & _ 
    "xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & _ 
    "<soap:Body>" & _ 
     "<GetListItems xmlns=""http://schemas.microsoft.com/sharepoint/soap/"">" & _ 
     "<listName>" & listName & "</listName>" & _ 
     "<query><Query>" & _ 
      "<Where><Eq><FieldRef Name=""ID""/><Value Type=""Integer"">" & itemId & "</Value></Eq></Where>" & _ 
      "</Query></query>" & _ 
      "<viewFields><ViewFields/></viewFields>" & _ 
     "</GetListItems>" & _ 
    "</soap:Body>" & _ 
"</soap:Envelope>" 


    Set xhr = CreateObject("MSXML2.ServerXMLHTTP.6.0") 
    xhr.Open "POST", webUrl & wsdl, False 
    xhr.setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
    xhr.setRequestHeader "SOAPAction", action 
    xhr.Send soap 

    MsgBox xhr.Status & ":" & xhr.statusText & vbCrLf & xhr.responseText 


End Sub 
+0

數據哇!這太棒了!非常感謝你爲我寫這篇文章。我真的在拉我的頭髮試圖弄清楚,這就像一個魅力! –