VBA to Access Metadata from File on SharePoint

JJorsi

New Member
Joined
Dec 20, 2016
Messages
6
Hello All,

I am trying to use VBA to access the metadata from a specific file on SharePoint. Basically there is a live file on SharePoint that is downloaded and used by many users. I want to incorporate a quick code that checks the metadata of the live file to see if the live version number matches the file being used (to then inform the user if their file is outdated).

I am not too familiar with using the SharePoint web services or SOAP - it has been a struggle to find anything relevant on this topic... I managed to do it one way but it required opening the live version in order to access the metadata and this caused too significant of a delay to implement.

I am trying to access the data using the SOAP method (and failing) so wondering if anyone has any suggestions or any better theories on how I can accomplish this? Here's what I've been using so far:

' Set SOAP/Webservice Parameters
Dim SOAPURL_Vers As String, SOAPListName As String, SOAPViewName As String
SOAPURL_Vers = "http://companysitename/link/link/link/link/grouppage/libraryname/_vti_bin/versions.asmx"
SOAPFileName = "sample_mm.xlsb"

Dim SOAPAction As String
SOAPAction = "http://schemas.microsoft.com/sharepoint/soap/GetVersions"

' SOAP Envelope
Dim SOAPEnvelope_Pre As String, SOAPEnvelope_Pst As String
SOAPEnvelope_Pre = "" & _
"<soap:envelope target="_blank" href="http://www.w3.org/2001/XMLSchema-instance" <a="" xmlns:xsi="">http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""XML Schema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & _
"<soap:body>"
SOAPEnvelope_Pst = "</soap:body>" & _
"</soap:envelope>"

' Complete the packet
Dim SOAPMessage As String
SOAPMessage = SOAPEnvelope_Pre & _
" <getversions xmlns="" target="_blank" href="http://schemas.microsoft.com/sharepoint/soap/" <a="">http://schemas.microsoft.com/sharepoint/soap/"">" & _
" <filename>" & SOAPFileName & "</filename>" & _
" </getversions>" & _
SOAPEnvelope_Pst

From here I was just trying to show the data I was pulling to try and make sense of it all...

' Create HTTP Object
Dim Request As Object
Set Request = CreateObject("MSXML2.ServerXMLHTTP.6.0")
' Call the service to get the List
Request.Open "POST", SOAPURL_Vers, False
Request.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
Request.setRequestHeader "SOAPAction", SOAPAction
Request.send (SOAPMessage)

MsgBox Request.Status & ":" & Request.statustext & vbCrLf & Request.responseText
MsgBox Right(Request.responseText, 1000)
Debug.Print Request.responseText

It doesn't seem to pull the version number (maybe it does but the data is too lengthy to even show in a message box... Please let me know if you have any better solutions or some way to clean this up and make it work..

Thanks!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Did you ever figure out a way to do any of this? I am trying to change the metadata on .PDF files on SharePoint and am looking for anyone who has had any success with this type of thing. Thanks.
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top