Get File Last Modified DateFunction GetLastModDate(strFilePathAndName As String) As Date
'USAGE:
' Immediate Window: ?GetLastModDate "C:\Temp\MyFile.xls"
' Returns: 6/22/2010 4:37:46 PM
Dim fso As Object
Dim f As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(strFilePathAndName)
GetLastModDate = f.DateLastModified
Set fso = Nothing
End Function Get File Created DateFunction GetCreatedDate(strFilePathAndName As String) As Date
'USAGE:
' Immediate Window: ?GetLastCreatedDate "C:\Temp\MyFile.xls"
' Returns: 6/22/2010 4:37:46 PM
Dim fso As Object
Dim f As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(strFilePathAndName)
GetCreatedDate = f.DateCreated
Set fso = Nothing
End Function Get File SizeFunction GetFileSize(strFilePathAndName As String) As String
'USAGE (returns in Megabytes):
' Immediate Window: ?GetFileSize "C:\Temp\MyFile.xls"
' Returns: 13.6 Mb
Dim fso As Object
Dim f As Object
Dim fsize As Double
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(strFilePathAndName)
fsize = (f.Size / 1024) / 1024
GetFileSize = Round(fsize, 2) & " Mb"
Set fso = Nothing
End Function
|