+ Reply to Thread
Results 1 to 2 of 2

Recording File Name, Last Modified Date AND Last Saved By properties within directory

Hybrid View

compton12345 Recording File Name, Last... 11-14-2013, 01:54 PM
Solus Rankin Re: Recording File Name, Last... 11-14-2013, 02:16 PM
  1. #1
    Registered User
    Join Date
    11-14-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    1

    Question Recording File Name, Last Modified Date AND Last Saved By properties within directory

    Hi all,

    I am looking for a way to loop through a directory (including subfolders) and record every file name, last modified date but most importantly (and proving most difficult) who was the last person/user to modify the file.

    I have got to this point:

    Option Explicit
    
    Sub ListFiles()
    
       
        Application.ScreenUpdating = False
        Dim objFSO As Scripting.FileSystemObject
        Dim objTopFolder As Scripting.Folder
        Dim strTopFolderName As String
        
    
        Range("A1").Value = "File Name"
        Range("B1").Value = "File Size"
        Range("C1").Value = "File Type"
        Range("D1").Value = "Date Created"
        Range("E1").Value = "Date Last Accessed"
        Range("F1").Value = "Date Last Modified"
    
        strTopFolderName = "C:\Documents and Settings\User\My Documents\Test Directory\"
        
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objTopFolder = objFSO.GetFolder(strTopFolderName)
        
        Call RecursiveFolder(objTopFolder, True)
        
    
        Columns.AutoFit
        Application.ScreenUpdating = True
    End Sub
    
    Sub RecursiveFolder(objFolder As Scripting.Folder, _
        IncludeSubFolders As Boolean)
    
        Dim objFile As Scripting.file
        Dim objSubFolder As Scripting.Folder
        Dim NextRow As Long
        
    
        NextRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
        
    
        For Each objFile In objFolder.Files
            Cells(NextRow, "A").Value = objFile.Name
            Cells(NextRow, "B").Value = objFile.Size
            Cells(NextRow, "C").Value = objFile.Type
            Cells(NextRow, "D").Value = objFile.DateCreated
            Cells(NextRow, "E").Value = objFile.DateLastAccessed
            Cells(NextRow, "F").Value = objFile.DateLastModified
      
            NextRow = NextRow + 1
        Next objFile
        
      
        If IncludeSubFolders Then
            For Each objSubFolder In objFolder.SubFolders
                Call RecursiveFolder(objSubFolder, True)
            Next objSubFolder
        End If
        
    End Sub
    This works fine but what I can't achieve in a similar way is the actual name of the person who last modified/accessed the file (happy for this to be a PC generated ID, can use a lookup table). This is further complicated by the fact that the files within the directory will be a mixture of Office files, mainly xls ppt and doc.

    Is this at all possible either through amending my code or using a completely new solution? The directory also may grow over time and I'm conscious this code may take a while to run. Am I missing a more efficient solution?

    Appreciate any help.

    Regards

    Alex

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Recording File Name, Last Modified Date AND Last Saved By properties within directory

    On the spreadsheets you can record the username of the individual who last saved, but I don't believe its part of the metadata that can be idendified by your scripting object.

    As for the other file types (besides spreadsheets) it will be even less easy than that.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Finding File Creation date, saved date and last modified date
    By david systems in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-22-2013, 05:49 PM
  2. Open Newest Modified File in Directory
    By mccrimmon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-19-2008, 05:48 AM
  3. Replies: 1
    Last Post: 02-21-2006, 12:55 AM
  4. Finding the last modified directory and file
    By shilparvind@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2005, 07:05 PM
  5. Replies: 1
    Last Post: 03-08-2005, 12:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1