View Full Version : Posting XML command to Windows SharePoint document library

03-24-2006, 02:42 AM
Hi !
'Have someone made posts from VBA code to Window SharePoint Services
docements library?
'Can someone suggest where i can get clear and working examples for posting data to WSS document library with VBA?
'I am using MSXML 5.0 library - is it usable or I have to use another

'My goal is fix metadata to existing files in my WSS doc library


'Code which does not work (i receive that ServerXMLHTTP.StatusTextis = "OK", but
no metadata will be added to existing document (file)):

Public Function MyPostXMLToWSS(ByVal strUser As String, _
ByVal strPass As String, _
ByVal strURL As String) As Boolean

Dim objServerXMLHTTP As MSXML2.ServerXMLHTTP50
Dim objXMLSend As MSXML2.DOMDocument50
Dim myErr As MSXML2.IXMLDOMParseError

Set objServerXMLHTTP = New MSXML2.ServerXMLHTTP50
Set objXMLSend = New MSXML2.DOMDocument50

On Error GoTo Errors

objXMLSend.async = False 'Synch. connection

'Load XML file (XML syntax according "Save" Method of WSS RPC -
objXMLSend.Load "C:\WSS.xml" '(Please see example XML in the 'end)

'Is it XML OK ?
If (objXMLSend.parseError.errorCode <> 0) Then
Set myErr = objXMLSend.parseError
MsgBox ("You have error " & myErr.reason)
GoTo Errors
Set myErr = objXMLSend.parseError
If (myErr.errorCode <> 0) Then
MsgBox ("You have error " & myErr.reason)
GoTo Errors
End If

End If

'Connection with HTTPS page
objServerXMLHTTP.Open "POST", "https://Someaddresse.ee/sites/SomeSite/default.aspx (https://someaddresse.ee/sites/SomeSite/default.aspx)", False, "user_X", "passwd_Y"

'Posting XML to HTTPS page
objServerXMLHTTP.Send objXMLSend

MyPostXMLToWSS = True

Exit Function
MyPostXMLToWSS = False

End Function

Example XML(WSS.xml):

<?xml version="1.0" encoding="UTF-16" ?>
-<Method ID="10,Save">
<SetVar Name="Cmd">Save</SetVar>
<SetVar Name="ID">10</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#Year">2006</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#Source">Aton Capital</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#Analyse type (main)">Flash Note</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#Analyse type (detailed)">monthly</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#Company">;#Adris Grupa;#Agora SA;#Antenna Hungaria Rt.;#Arenaturist dd;#</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#Country">;#Austria;#Bulgaria;#Croatia;#Czech;#</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#Sector (main)">;#Financials, Funds & Holdings;#Healthcare & Consumer;#Industrials & Utilities;#Materials & Energy;#</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#Sector (detailed)">;#Automobiles & Components;#Banks;#Capital Goods;#Construction;#</SetVar>