I tried a few times to figure this out but can't figure out how to get Last Saved By name in excel-
.Cells(, 1).Value = fil.Name
.Cells(, 2).Value = fld.Path
.Cells(, 3).Value = Right(fil.Name, Len(fil.Name) - InStrRev(fil.Name, "."))
.Cells(, 4).Value = fil.DateCreated
.Cells(, 5).Value = fil.DateLastAccessed
.Cells(, 6).Value = fil.DateLastModified
.Cells(, 7).Value = fil.LastAuthor (this doesn't work)
here is the full VBA code without the last author / last saved by
Option Explicit
Sub AllFileFolder()
Dim strPath As String
Dim sht As Worksheet
Dim rng As Range
Dim Path As String
Dim fso As Object
Dim fld As Object
Dim fil As Object
strPath = "\\DrivePath"
Set sht = ActiveWorkbook.Worksheets.Add
Set rng = sht.Cells(1, 1)
rng.Resize(, 6).Value = Array("FileName", "FileLocation", "Extension", "CreationDate", "LastAccessDate", "LastModficationDate")
Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(strPath)
getFilesFromFolder fld, rng
MsgBox "Done", vbOKOnly + vbInformation, "Done"
End Sub
Private Sub getFilesFromFolder(fld As Object, rng As Range)
Dim subfld As Object
Dim fil As Object
On Error GoTo ErrHandler
For Each fil In fld.Files
DoEvents
Set rng = rng.Offset(1)
With rng
.Cells(, 1).Value = fil.Name
.Cells(, 2).Value = fld.Path
.Cells(, 3).Value = Right(fil.Name, Len(fil.Name) - InStrRev(fil.Name, "."))
.Cells(, 4).Value = fil.DateCreated
.Cells(, 5).Value = fil.DateLastAccessed
.Cells(, 6).Value = fil.DateLastModified
End With
Next fil
For Each subfld In fld.SubFolders
getFilesFromFolder subfld, rng
Next subfld
ErrHandler:
End Sub
.Cells(, 1).Value = fil.Name
.Cells(, 2).Value = fld.Path
.Cells(, 3).Value = Right(fil.Name, Len(fil.Name) - InStrRev(fil.Name, "."))
.Cells(, 4).Value = fil.DateCreated
.Cells(, 5).Value = fil.DateLastAccessed
.Cells(, 6).Value = fil.DateLastModified
.Cells(, 7).Value = fil.LastAuthor (this doesn't work)
here is the full VBA code without the last author / last saved by
Option Explicit
Sub AllFileFolder()
Dim strPath As String
Dim sht As Worksheet
Dim rng As Range
Dim Path As String
Dim fso As Object
Dim fld As Object
Dim fil As Object
strPath = "\\DrivePath"
Set sht = ActiveWorkbook.Worksheets.Add
Set rng = sht.Cells(1, 1)
rng.Resize(, 6).Value = Array("FileName", "FileLocation", "Extension", "CreationDate", "LastAccessDate", "LastModficationDate")
Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(strPath)
getFilesFromFolder fld, rng
MsgBox "Done", vbOKOnly + vbInformation, "Done"
End Sub
Private Sub getFilesFromFolder(fld As Object, rng As Range)
Dim subfld As Object
Dim fil As Object
On Error GoTo ErrHandler
For Each fil In fld.Files
DoEvents
Set rng = rng.Offset(1)
With rng
.Cells(, 1).Value = fil.Name
.Cells(, 2).Value = fld.Path
.Cells(, 3).Value = Right(fil.Name, Len(fil.Name) - InStrRev(fil.Name, "."))
.Cells(, 4).Value = fil.DateCreated
.Cells(, 5).Value = fil.DateLastAccessed
.Cells(, 6).Value = fil.DateLastModified
End With
Next fil
For Each subfld In fld.SubFolders
getFilesFromFolder subfld, rng
Next subfld
ErrHandler:
End Sub