A
Alan Webb
Can anyone explain to me why the list resulting from the
following code should return answers such as:
File Created Modified Accessed
Name 16/2/02 30/8/02 13/11/01
Needless to say it is the Accessed reply that throws me
being 3 months before the created date!!
'Code from here
Sub File_Spec()
Dim f
Dim pName As String 'Path name
Dim fName As String 'File name
pName = Application.GetOpenFilename(Title:="Select a file
in the directory to report on:")
For f = Len(pName) To 1 Step -1
If Mid(pName, f, 1) = "\" Then
pName = Left(pName, f)
Exit For
End If
Next f
fName = Dir(pName & "*.*")
ActiveWorkbook.Worksheets.Add
Cells(1, 1) = "File name"
Cells(1, 2) = "Date Created"
Cells(1, 3) = "Date Last Accessed"
Cells(1, 4) = "Date Last Modified"
Cells(1, 5) = "Path"
Do While (Len(fName) > 0)
fName = Dir()
If (Len(fName) > 0) And ((fName <> ".") And (fName
<> "..")) Then
ShowFileAccessInfo fName, pName
End If
Loop
Columns("A:E").AutoFit
End Sub
Sub ShowFileAccessInfo(filespec, pathspec)
Dim fs, f, s
Dim r
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(pathspec & filespec)
r = ActiveSheet.UsedRange.Rows.Count + 1
Cells(r, 1) = filespec
Cells(r, 2) = f.DateCreated
Cells(r, 3) = f.DateLastAccessed
Cells(r, 4) = f.DateLastModified
Cells(r, 5) = pathspec
End Sub
following code should return answers such as:
File Created Modified Accessed
Name 16/2/02 30/8/02 13/11/01
Needless to say it is the Accessed reply that throws me
being 3 months before the created date!!
'Code from here
Sub File_Spec()
Dim f
Dim pName As String 'Path name
Dim fName As String 'File name
pName = Application.GetOpenFilename(Title:="Select a file
in the directory to report on:")
For f = Len(pName) To 1 Step -1
If Mid(pName, f, 1) = "\" Then
pName = Left(pName, f)
Exit For
End If
Next f
fName = Dir(pName & "*.*")
ActiveWorkbook.Worksheets.Add
Cells(1, 1) = "File name"
Cells(1, 2) = "Date Created"
Cells(1, 3) = "Date Last Accessed"
Cells(1, 4) = "Date Last Modified"
Cells(1, 5) = "Path"
Do While (Len(fName) > 0)
fName = Dir()
If (Len(fName) > 0) And ((fName <> ".") And (fName
<> "..")) Then
ShowFileAccessInfo fName, pName
End If
Loop
Columns("A:E").AutoFit
End Sub
Sub ShowFileAccessInfo(filespec, pathspec)
Dim fs, f, s
Dim r
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(pathspec & filespec)
r = ActiveSheet.UsedRange.Rows.Count + 1
Cells(r, 1) = filespec
Cells(r, 2) = f.DateCreated
Cells(r, 3) = f.DateLastAccessed
Cells(r, 4) = f.DateLastModified
Cells(r, 5) = pathspec
End Sub