Results 1 to 3 of 3

Add date last modified

Threaded View

  1. #1
    Registered User
    Join Date
    10-13-2014
    Location
    Albuquerque, NM
    MS-Off Ver
    2013
    Posts
    3

    Add date last modified

    Hello,

    I have been researching for the past week to see if a VBA code exists that can meet my request. So far, I found a VBA that has met 90%. My last request is to see if each file found in each subfolder can list in column D the 'datelastmodified'. Any help is appreciated!
    Thanks

     Option Explicit
     
    Public Sub Hierarchical_Folders_and_Files_Listing()
         
        Dim startFolderPath As String
        Dim startCell As Range
         
        startFolderPath = "C:\"
         
        Set startCell = Sheets("Sheet1").Range("A11")
        startCell.Parent.Cells.Clear
         
        List_Folders_and_Files startFolderPath, startCell
         
    End Sub
     
     
    Private Function List_Folders_and_Files(folderPath As String, destCell As Range) As Long
         
        Static FSO As Object
        Dim thisFolder As Object, subfolder As Object
        Dim fileItem As Object
        Dim n As Long
         
        If FSO Is Nothing Then Set FSO = CreateObject("Scripting.FileSystemObject")
         
        Set thisFolder = FSO.GetFolder(folderPath)
         
         'Add hyperlink for this folder
         
        destCell.Parent.Hyperlinks.Add Anchor:=destCell, Address:=thisFolder.Path, TextToDisplay:=thisFolder.Name
         
         'List subfolders and files in this folder
         
        For Each subfolder In thisFolder.Subfolders
            Set destCell = destCell.Offset(0, 1)
            Set destCell = destCell.Offset(List_Folders_and_Files(subfolder.Path, destCell), -1)
        Next
         
         'Add hyperlink for each file in this folder
         
        n = 0
        For Each fileItem In thisFolder.Files
            destCell.Offset(n, 1).Parent.Hyperlinks.Add Anchor:=destCell.Offset(n, 1), Address:=fileItem.Path, TextToDisplay:=fileItem.Name
            n = n + 1
        Next
         
        List_Folders_and_Files = n
         
    End Function
    Last edited by Smoovin; 10-14-2014 at 02:28 PM.

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. Template needed with footer containing date created and date modified
    By MitchHull in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-31-2012, 04:37 PM
  3. Inserting a date modified,or date inserted row
    By komet12 in forum Excel General
    Replies: 0
    Last Post: 08-25-2011, 07:50 AM
  4. csv modified date
    By jtwork in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-06-2007, 04:43 AM
  5. date modified
    By flow23 in forum Excel General
    Replies: 1
    Last Post: 11-24-2005, 08:30 AM

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