VBA Last modified date of a file

Опубликовано: 04 Ноябрь 2024
на канале: Simplified Excellence
3,645
15

Retrieve the last modified date of a file or multiple files.

Code:
Sub check_last_modified_date_file()

Dim fs As Object
Dim current_file As Object
Dim date_last_modified As Date
Dim path_current_file As String

'path of the file to check
path_current_file = "C:\Users\brunduk\Documents\Tutorials\My PDF.pdf"

Set fs = CreateObject("Scripting.FileSystemObject")
Set current_file = fs.GetFile(path_current_file)

'identify last modified date
date_last_modified = Format(current_file.DateLastModified, "mm/dd/yyyy")

'display date
MsgBox ("The last modified date is: " & date_last_modified)

End Sub

-------------------------------
NEED HELP?
-------------------------------
Leave a comment with your questions, issues or projetcs and I will try to answer with a video.

-------------------------------
THANK YOU
-------------------------------
For watching my videos,
Your shares
And your comments!