PDA

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



Lammutaja
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
library?

'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 -
'http://msdn.microsoft.com/library/en-'us/spptsdk/html/tsrpcmSave_SV01107410.asp)
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
Else
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
Errors:
MyPostXMLToWSS = False

End Function

----------------------------------------------------------
Example XML(WSS.xml):

<?xml version="1.0" encoding="UTF-16" ?>
-<Method ID="10,Save">
<SetList>{C9C8A8B8-69FD-4F2D-9F86-DDF84879C213}</SetList>
<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>
</Method>