See Also Example
Returns a String that indicates the date and time a specified file was created or last modified.
The argument filename can be any string expression The file specification may include optional drive and path information. that contains an unambiguous (no wildcards) file specification.
FileDateTime Function Example
The example uses FileDateTime to get date and time information about when a file was created or last modified. File date and time information is displayed in a message box anytime you choose the name of a file in the file list box. To try this example, paste the code into the Declarations section of a form containing a file list box named File1. Then press F5 to start.
Sub File1_Click ()
Dim Msg, TimeStamp ' Declare variables.
FName = File1.FileName ' Get selected file name.
TimeStamp = FileDateTime(FName) ' Get file date/time info.
Msg = UCase(FName) & " was created or last modified on "
Msg = Msg & Format(TimeStamp, "dddddd") & " at "
Msg = Msg & Format(TimeStamp, "h:mm AM/PM") & ". Its size is "
Msg = Msg & FileLen(FName) & " bytes." ' Get file size.
MsgBox Msg ' Display message.