davestuart
Registered User.
- Local time
- Yesterday, 19:21
- Joined
- Feb 7, 2014
- Messages
- 15
I have written VBA code that will upload a document to SharePoint 2010/2013. Then I get the record via ADODB using the document Name and update the metadata. This all working great, however this created 2 revisions as Versioning is on, which is what I need. I would like to know how I can upload a docyment AND set the metadata in one transaction via MS Access VBA 2010?
This is a sub-set of the code.
Thanks
Dave
This is a sub-set of the code.
Code:
Set objXML = New XMLHTTP 'CreateObject("Microsoft.XMLHTTP")
Dim bytBinary() As Byte
Dim strSharePointUrl As String
Dim strSharePointFileName As String
Dim strFileName As String
'
ReDim bytBinary(lngFileLength)
Open strFullfileName For Binary As #1
Get #1, , bytBinary
Close #1
'
' Convert to variant to PUT.
varBinData = bytBinary
strTargetURL = strSharePointFileName
'
' Put the data to the server, false means synchronous.
objXML.Open "PUT", strTargetURL, False ', username, password
'
On Error Resume Next
' Send the file in. Note that the Name field in SharePoint is updated with the filename.
objXML.send varBinData
'
'IMORTANT: The WILDCARD is % and NOT * because this is a SQL Table and ADO Connection!
rst.Open "SELECT * FROM [" & strListName & "] WHERE [Name] Like '%" & strFileName & "%'", cnn, adOpenDynamic, adLockOptimistic
'
'Note that Manditory fields will cause the List/Library Item to check Out the item
'Not sure how to check in at the moment.
If Not rst.EOF Then
'Debug.Print "ID:" & rst("ID") & " Name:" & rst("Name")
'
'SharePoint Item Update
rst("Name") = strFileName
rst("Title") = !Title
rst("Originator") = !Originator
etc....
Thanks
Dave