Excel FileDateTime Function (VBA)
How to use the FileDateTime Function (VBA)
This Excel tutorial explains how to use the Excel FileDateTime function with syntax and examples using VBA.
SUMMARY:
The Excel VBA FileDateTime function returns the date and time of when a file was created or last modified.
PURPOSE:
To get the date and time when a file was created or last modified.
RETURN VALUE:
The FileDateTime function returns a Date value.
SYNTAX:
FileDateTime(pathname)
ARGUMENTS:
The FileDateTime function syntax has the following arguments:
- pathname: Required. The pathname argument is a string expression that specifies a file name.
- The pathname may include the directory or folder, and the drive.
REMARKS:
- If the specified file is not available then an error will occur.
FileDateTime Function VBA Code example:
Diffrent way to use the FileDateTime function using Excel VBA Code...
FileDateTime Function Example (as VBA code)
The FileDateTime function can only be used in VBA code in Microsoft Excel.
The following VBA code shows how the FileDateTime function used to get the date and time when a file or directory was created or last modified.
Dim testResult As Date
testResult = FileDateTime("C:\myprofile.jpg")
In the above VBA code example, The testResult variable would now contain the create or last modified date for the myprofile.jpg file.
VBA FileDateTime Function Error:
If you supply
invalid path/name of the file to the FileDateTime function, you will get the error:
Run-time error '76': Path not found
Download Example Sample Excel File
FileDateTime-function-example.xlsm
Useful Links:
Link 1…
Link 2…
Link 3…
Link 4…