Hello,
I used code from the below link to get information on files that reside at a specific folder (which include name, datelastmodified, size, type, etc)
http://www.exceltip.com/st/List_fil...Runtime_using_VBA_in_Microsoft_Excel/446.html
But in addition to this I'd like to get information that's stored on the summary tab if you view a file's properties (i.e. Author, Keywords, Comments, etc)
Is there a way to do this?
This is the code I'm working with, but I get an error it attempts to get "Author"
Sub TestListFilesInFolder2()
Workbooks.Add ' create a new workbook for the file list
' add headers
With Range("A1")
.Formula = "Folder contents:"
.Font.Bold = True
.Font.Size = 12
End With
Range("A3").Formula = "File Name"
Range("B3").Formula = "Size"
Range("C3").Formula = "Type"
Range("D3").Formula = "Date Last Modified"
Range("E3").Formula = "Author"
Range("A3:E3").Font.Bold = True
'ListFilesInFolder2 "C:\Test\", True
End Sub
Sub ListFilesInFolder2(SourceFolderName As String, IncludeSubfolders As Boolean)
' lists information about the files in SourceFolder
' example: ListFilesInFolder "C:\FolderName\", True
Dim FSO As Scripting.FileSystemObject
'
'Dim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder
'Dim FileItem As Scripting.File
Dim r As Long
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(SourceFolderName)
r = Range("A65536").End(xlUp).Row + 1
For Each FileItem In SourceFolder.Files
Cells(r, 1).Formula = FileItem.Name
Cells(r, 2).Formula = FileItem.Size
Cells(r, 3).Formula = FileItem.Type
Cells(r, 4).Formula = FileItem.DateLastModified
'Cells(r, 5).Formula = FileItem.Author **this doesn't work**
r = r + 1 ' next row number
Next FileItem
If IncludeSubfolders Then
For Each SubFolder In SourceFolder.SubFolders
ListFilesInFolder SubFolder.Path, True
Next SubFolder
End If
Columns("B:E").AutoFit
Set FileItem = Nothing
Set SourceFolder = Nothing
Set FSO = Nothing
ActiveWorkbook.Saved = True
End Sub
I used code from the below link to get information on files that reside at a specific folder (which include name, datelastmodified, size, type, etc)
http://www.exceltip.com/st/List_fil...Runtime_using_VBA_in_Microsoft_Excel/446.html
But in addition to this I'd like to get information that's stored on the summary tab if you view a file's properties (i.e. Author, Keywords, Comments, etc)
Is there a way to do this?
This is the code I'm working with, but I get an error it attempts to get "Author"
Sub TestListFilesInFolder2()
Workbooks.Add ' create a new workbook for the file list
' add headers
With Range("A1")
.Formula = "Folder contents:"
.Font.Bold = True
.Font.Size = 12
End With
Range("A3").Formula = "File Name"
Range("B3").Formula = "Size"
Range("C3").Formula = "Type"
Range("D3").Formula = "Date Last Modified"
Range("E3").Formula = "Author"
Range("A3:E3").Font.Bold = True
'ListFilesInFolder2 "C:\Test\", True
End Sub
Sub ListFilesInFolder2(SourceFolderName As String, IncludeSubfolders As Boolean)
' lists information about the files in SourceFolder
' example: ListFilesInFolder "C:\FolderName\", True
Dim FSO As Scripting.FileSystemObject
'
'Dim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder
'Dim FileItem As Scripting.File
Dim r As Long
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(SourceFolderName)
r = Range("A65536").End(xlUp).Row + 1
For Each FileItem In SourceFolder.Files
Cells(r, 1).Formula = FileItem.Name
Cells(r, 2).Formula = FileItem.Size
Cells(r, 3).Formula = FileItem.Type
Cells(r, 4).Formula = FileItem.DateLastModified
'Cells(r, 5).Formula = FileItem.Author **this doesn't work**
r = r + 1 ' next row number
Next FileItem
If IncludeSubfolders Then
For Each SubFolder In SourceFolder.SubFolders
ListFilesInFolder SubFolder.Path, True
Next SubFolder
End If
Columns("B:E").AutoFit
Set FileItem = Nothing
Set SourceFolder = Nothing
Set FSO = Nothing
ActiveWorkbook.Saved = True
End Sub