Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Alan,
First of all.. : did you notice the first file never get's listed..? move fname=dir() down to just before the loop and you're fine. Next: the dates on my system are correct, but I suspect that it's related to a setting of the windows filesystem. Several XP tuning/tweaking proggies allow you to turn off NTFS's tracking of the last access date. -- keepITcool | www.XLsupport.com | keepITcool chello nl | amsterdam Alan Webb wrote : 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"keepITcool" wrote in message ...
Alan, First of all.. : did you notice the first file never get's listed..? move fname=dir() down to just before the loop and you're fine. Next: the dates on my system are correct, but I suspect that it's related to a setting of the windows filesystem. Several XP tuning/tweaking proggies allow you to turn off NTFS's tracking of the last access date. Thanks, must admit I hadn't noticed but will have a look at that. On the system I am using at work I shall not be able to check on the access tracking so will have to live with that |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Comment Box in Properties of Excel files | Excel Discussion (Misc queries) | |||
check properties of 400 Excel files | Excel Discussion (Misc queries) | |||
Files properties | Excel Programming | |||
Files properties | Excel Programming | |||
Accessing document properties of non-Microsoft product files | Excel Programming |