Good morning,
I am trying to work out how to amend this code so i can get the file attributes for each of the files (listed in Column A)
The current code is just pulling all the files from the pathway, but i only need specifically the details of certain files (in Column A) ie DateCreated and DateLast
Modified
Examples of files in Column A
The current code
Sub ListAllFiles()
Dim objFSO As Scripting.FileSystemObject
Dim objFolder As Scripting.Folder
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("S:\Other\Datafeeds\Cpens\")
Call GetFileDetails(objFolder)
End Sub
Function GetFileDetails(objFolder As Scripting.Folder)
Dim objFile As Scripting.File
Dim nextRow As Long
Dim objSubFolder As Scripting.Folder
nextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
For Each objFile In objFolder.Files
Cells(nextRow, 1) = objFile.Name
Cells(nextRow, 2) = objFile.Path
Cells(nextRow, 3) = objFile.Size
Cells(nextRow, 4) = objFile.Type
Cells(nextRow, 5) = objFile.DateCreated
Cells(nextRow, 6) = objFile.DateLastModified
nextRow = nextRow + 1
Next
For Each objSubFolder In objFolder.SubFolders
Call GetFileDetails(objSubFolder)
Next
End Function
Much appreciated if you can assist.
Regards
M
I am trying to work out how to amend this code so i can get the file attributes for each of the files (listed in Column A)
The current code is just pulling all the files from the pathway, but i only need specifically the details of certain files (in Column A) ie DateCreated and DateLast
Modified
Examples of files in Column A
BAF_GBP_IDX_20240214.csv |
BAR_AVG_IDX_20240214.csv |
BAR_IDX_20240214.csv |
BCI_IDX_20240214.csv |
The current code
Sub ListAllFiles()
Dim objFSO As Scripting.FileSystemObject
Dim objFolder As Scripting.Folder
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("S:\Other\Datafeeds\Cpens\")
Call GetFileDetails(objFolder)
End Sub
Function GetFileDetails(objFolder As Scripting.Folder)
Dim objFile As Scripting.File
Dim nextRow As Long
Dim objSubFolder As Scripting.Folder
nextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
For Each objFile In objFolder.Files
Cells(nextRow, 1) = objFile.Name
Cells(nextRow, 2) = objFile.Path
Cells(nextRow, 3) = objFile.Size
Cells(nextRow, 4) = objFile.Type
Cells(nextRow, 5) = objFile.DateCreated
Cells(nextRow, 6) = objFile.DateLastModified
nextRow = nextRow + 1
Next
For Each objSubFolder In objFolder.SubFolders
Call GetFileDetails(objSubFolder)
Next
End Function
Much appreciated if you can assist.
Regards
M