Creating SharePoint list item with vbscript and WebServices

Few days back I had some urgent requirement to create and update a sharepoint list item using vbscript and sharepoint WebServices. After goggling a bit i found a solution in one of the msdn forums .. so posting the code here with my additions

Code :
Sub AddListItem(site, listGUID, itemTitle)
strEndPointURL = "http://moss" + site + "/_vti_bin/Lists.asmx"
Set objSOAPConnector = CreateObject("MSOSOAP.HttpConnector30")
with objSOAPConnector
.Property("EndPointURL") = strEndPointURL
.Property("SoapAction") = strSoapAction
End With
Set objSOAPSerializer = CreateObject("MSOSoap.SoapSerializer30")
with objSOAPSerializer
.StartElement "UpdateListItems", ""
.StartElement "listName", ""
.StartElement "updates",""
.StartElement "Batch"
.SoapAttribute "ListName", ,listGUID
.SoapAttribute "OnError", ,"Continue"
.StartElement "Method"
.SoapAttribute "ID", ,"1"
.SoapAttribute "Cmd", ,"New"
.StartElement "Field"
.SoapAttribute "Name", ,"Title"
End With
Set objResponseReader = CreateObject("MSOSOAP.SoapReader30")
Wscript.echo objResponseReader.Body.xml
End Sub



This is a personal weblog. The opinions expressed here represent my own and not those of my employer or anyone else. Should you have any questions or concerns please e-mail me at .

Copyright (c) 2010 @ All rights are reserved.Do Not Copy.

@ Learning