OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 439
- Office Version
- 2019
- Platform
- Windows
Thanks in advance and feedback will be given for any suggestions.
I've done an exhaustive search and anything I find and try to incorporate is giving issues. How do I add the date created and date modified to this file. It currently get the file name and places it in column A, and I would like the date created and date last modified to be in columns B and C respectively.
These lines I was trying to code to get that:
I've done an exhaustive search and anything I find and try to incorporate is giving issues. How do I add the date created and date modified to this file. It currently get the file name and places it in column A, and I would like the date created and date last modified to be in columns B and C respectively.
These lines I was trying to code to get that:
Code:
'Sheets("List").Cells(i, 2).Value = Date created should be coded in this line
'Sheets("List").Cells(i, 2).Value = Date modified should be coded in this line
Code:
Sub GetFileNames()
'Dimensioning
Dim Folder As String
Dim ObjFSO As Object
Dim ObjFolder As Object
Dim ObjFile As Object
Dim i As Integer
If Right(Sheets("List").Cells(3, 2).Value, 1) <> "\" Then
Sheets("List").Cells(3, 2).Value = Sheets("List").Cells(3, 2).Value & "\"
End If
DirFolderRename = Sheets("List").Cells(3, 2).Value
i = 5
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
Set ObjFolder = ObjFSO.GetFolder(DirFolderRename)
For Each ObjFile In ObjFolder.Files
Sheets("List").Cells(i, 1).Value = ObjFile.Name
'Sheets("List").Cells(i, 2).Value = Date created should be coded in this line
'Sheets("List").Cells(i, 2).Value = Date modified should be coded in this line
i = i + 1
Next ObjFile
End Sub