Hi! Could anyone please help me with this issue?
I'm trying to add a record to an existing list on SharePoint using VBA. I run my code but nothing happens.
Sub Add_Item() Dim ListName As String Dim SharepointUrl As String Dim ValueVar As String Dim FieldNameVar As String Dim objXMLHTTP As MSXML2.XMLHTTP Dim strListNameOrGuid As String Dim strBatchXml As String Dim strSoapBody As String Set objXMLHTTP = New MSXML2.XMLHTTP
'My list's name strListNameOrGuid = "Test" 'Add New Item' strBatchXml = "<Batch OnError='Continue'><Method ID='1' Cmd='New'><Field Name='ID'>3</Field>" _& "<Field Name=NOME>" + "test001" + "</Field>" _& "<Field Name=NOME2>" + "test002" + "</Field>" _& "</Method></Batch>" objXMLHTTP.Open "POST", "http://sharepoint.address.com/_vti_bin/Lists.asmx", False objXMLHTTP.setRequestHeader "Content-Type", "text/xml; charset=""UTF-8""" objXMLHTTP.setRequestHeader "SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems" strSoapBody = "<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><UpdateListItems " _& "xmlns='http://schemas.microsoft.com/sharepoint/soap/'><listName>" & strListNameOrGuid _& "</listName><updates>" & strBatchXml & "</updates></UpdateListItems></soap:Body></soap:Envelope>" objXMLHTTP.send strSoapBody Set objXMLHTTP = Nothing End Sub
One thing is that I tried accessing this website but it seems that it does not exist anymore... http://schemas.microsoft.com/sharepoint/soap/
I play this Macro and absolutely nothing is happening!!! Any tips?