Hi,
To get or retrieve the created date of an Excel file saved in SharePoint using VBA, you can use the SharePoint Object Model.
Here's an example code snippet-
Sub GetSharePointFileCreatedDate()
Dim siteUrl As String
Dim fileUrl As String
Dim spSite As Object
Dim spWeb As Object
Dim spFile As Object
' Set the SharePoint site URL
siteUrl = "https://your-sharepoint-site-url"
' Set the file URL (relative to the SharePoint site)
fileUrl = "/sites/your-site/library/your-excel-file.xlsx"
' Create SharePoint site and web objects
Set spSite = CreateObject("SPSite")
Set spWeb = spSite.OpenWeb(siteUrl)
' Get the file from SharePoint
Set spFile = spWeb.GetFile(fileUrl)
' Display the created date of the file
MsgBox "Created Date: " & spFile.TimeCreated
' Clean up objects
Set spFile = Nothing
spWeb.Close
spSite.Close
End Sub
Make sure to replace the siteUrl
and fileUrl
variables with the actual SharePoint site URL and the relative file URL within the site. When you run the GetSharePointFileCreatedDate
subroutine, it will retrieve the created date of the specified Excel file saved in SharePoint and display it in a message box.
Best Regards.