1

I need to get the Last Modified Data of excel file to a variable from Share point.

I have excel file In sharepoint which will be updated weekly. I just need to get the lats modified date in a variable to proceed with my macro. Please Help.

Thanks in Advance!!!

2 Answers 2

2

Check this solution from exceluser.com:

Public Function LastSaveTime() As String
   Application.Volatile
   LastSaveTime = ThisWorkbook.BuiltinDocumentProperties("Last Save Time")
End Function

This should also work with a Workbook which is stored in a sharepoint library - just tested it with SharePoint 2010

Edit to grab data from SharePoint List:

Check this Link - there it is explained how you are able to read list data into excel.

With this Link you will be able to get the ListName and the ViewName.

With those 2 combined the easiest way would be to create a new view for the list and add only the change column to the view - when the data has been imported to excel you can read that data easily and drop the added table again.

Hope this helps to get you in the right direction. (Tested and working with SP2010 List)

Sign up to request clarification or add additional context in comments.

1 Comment

Thank You therak. But I need code to get last modied Date from SharePoint. Can you Please provide me code to get the Date without opeing the workbook from sharepoint...
0
Sub TestWhen()

    SPFilePath = "http://teams.MyCompany.com/sites/PATH/PATH/Fulfillment/Forms/AllItems.aspx"

    Debug.Print SPLastModified(SPFilePath, "2021_MyFileName.xlsx")

End Sub


Function SPLastModified(SPUrl As String, SPFName As String)
    Dim ie As Object
    Dim PagesHTML As String
    Dim Dadate As String
    Dim DaDateEnd As String
    Dim arr() As String
    arr = Split(OutString, " ")
 
    Dim LastChange As Variant

    Set ie = CreateObject("InternetExplorer.Application")

    With ie
        .Visible = True
        .navigate SPUrl
        Do Until .readyState = 4
            DoEvents
        Loop
    
        Do While .busy: DoEvents: Loop

        Do Until .readyState = 4
            DoEvents
        Loop
        PagesHTML = ie.document.DocumentElement.outerHTML
    End With

' Get to File
    Dadate = InStr(PagesHTML, "FileLeafRef" & Chr(34) & ": " & Chr(34) & SPFName)

' Get to Modified Date
    ModifiedText = "Modified" & Chr(34) & ": "
    Dadate = Dadate + InStr(Mid(PagesHTML, Dadate), ModifiedText)

    OutString = Mid(PagesHTML, Dadate + Len(ModifiedText), 27)

    arr = Split(OutString, " ")
   
    LastChange = arr(1) & " " & arr(2)    
    LastChange = arr(0) & "/" & Mid(arr(1), 6) & "/" & Mid(arr(2), 6, 4) & " " & LastChange

    SPLastModified = LastChange

End Function

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.