View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
PcolaITGuy PcolaITGuy is offline
external usenet poster
 
Posts: 15
Default Getting FileSystem Date

Thanks very much for the advice. It worked great.!

"B Lynn B" wrote:

Instead of objFile.date, you probably want objFile.DateLastModified or
objFile.DateCreated

"PcolaITGuy" wrote:

I found the code below to read a directory and list the filenames and bytes
into a worksheet. This is great but I also need the file system date for
each file. For the life of me I cannot find the correct property to use.
Here's the code I have that essentially won't give me the file date:

Sub GetAttributes()
On Error Resume Next
Dim FolderPath 'Path to search for files
Dim objFSO 'fileSystemObject
Dim objFolder 'folder object
Dim colFiles 'Collection of files from files method
Dim objFile 'individual file object
Dim ws
Dim x
FolderPath = "C:\batchtest\" ' File Path

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FolderPath)
Set colFiles = objFolder.Files
Set ws = ActiveWorkbook.Worksheets(1)
x = 1
For Each objFile In colFiles
ws.Cells(x, 1).Value = objFile.Name
ws.Cells(x, 2).Value = objFile.Date
x = x + 1
Next
End Sub


Thanks in advance!