January 31, 2019
Hi all,
I´m looking for a way to read the meta data form single files, like "Creation Date", or "Modify Date" to use it as information for the user on a separate column or wherever.
I read, that it is obviously possible, if I load the data from a folder, but I haven´t found anything yet that explains the way, how to get these information from a single file.
Do you know, how?
Thx
best regards, Christoph
Trusted Members
October 18, 2018
Maybe this VBA will help you?
Sub ListAllFile()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim ws As Worksheet
Dim sPath As String
Dim lrA As Long
Dim lrB As Long
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ws = Worksheets.Add
'Get the folder object associated with the directory
sPath = InputBox("What is the full Path to Search?")
Set objFolder = objFSO.GetFolder(sPath)
ws.Cells(1, 1).Value = "The files found in " & objFolder.Name & " are:"
ws.Cells(1, 2).Value = "The files found have modified dates:"
ws.Cells(1, 3).Value = "The file Size is:"
'Loop through the Files collection
For Each objFile In objFolder.Files
'If objFile.Name Like "*.txt" Then
lrA = Range("A" & Rows.Count).End(xlUp).Row
lrB = Range("B" & Rows.Count).End(xlUp).Row
ws.Range("A" & lrA + 1).Value = objFile.Name
ws.Range("B" & lrB + 1).Value = objFile.DateLastModified
ws.Range("C" & lrB + 1).Value = objFile.Size
'End If
Next
'ws.Cells(2, 1).Delete
'Clean up!
Set objFolder = Nothing
Set objFile = Nothing
Set objFSO = Nothing
End Sub
1 Guest(s)