Guest_imported
New member
- Jan 1, 1970
- 0
I need to make something that will give me all the create dates for word documents in my directory.
Is the script below going to do that for me and if not please advise how I could do this??
Here is what I found but keep getting error message with FILETIME part.
[tt]
Dim hFile As Long ' handle to the opened file
Dim ctime As FILETIME ' receives time of creation
Dim atime As FILETIME ' receives time of last access
Dim mtime As FILETIME ' receives time of last modification
Dim thetime As SYSTEMTIME ' used to manipulate the time
Dim retval As Long ' return value
' First, open the file C:\Mydir\ for read-level access. Note the
' expression necessary to pass 0 as lpSecurityAttributes.
hFile = CreateFile("C:\Mydir", GENERIC_READ, FILE_SHARE_READ, ByVal CLng(0), OPEN_EXISTING, FILE_ATTRIBUTE_ARCHIVE, 0)
If hFile = -1 Then
Debug.Print "Could not open the file successfully -- aborting."
End ' terminate the program
End If
' Next, get the creation, last-access, and last-modification times.
retval = GetFileTime(hFile, ctime, atime, mtime)
' Convert the creation time to the local time zone.
retval = FileTimeToLocalFileTime(ctime, ctime)
' Convert the FILETIME format to the SYSTEMTIME format.
retval = FileTimeToSystemTime(ctime, thetime)
' Display the date of creation of the file to the user.
Debug.Print "The file was created on "; thetime.wMonth; "-"; thetime.wDay; "-"; thetime.wYear
' Close the file to free up resources.
retval = CloseHandle(hFile)[/tt]