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