+ Reply to Thread
Results 1 to 7 of 7

Search for old files by last accessed from a designated folder

  1. #1
    Registered User
    Join Date
    03-08-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    6

    Search for old files by last accessed from a designated folder

    I want users to be able to see a list of files they last accessed over a period of time, then to select through a multiselect listbox and kill the files. My problem comes when trying to import the last accessed date along with the file details(Which the code below does quite adequately). The displaying and killing of the files isn't a problem it's just finding the last accessed date and display in the column next to the file details. This my first post so please be nice to me. Thanks in advance Dave
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 03-24-2010 at 05:46 PM. Reason: Addded Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Search for old files by last accessed from a designated folder

    Hello bodiewil,

    You will need to need to use the File System Object to get the last modified date and to recurse the subfolders. Excel 2007 and later no longer uses the Application.FileSearch. The last argument of this macro is a boolean value. True will recurse through all the subfolders of the source folder listing the files and false lists only the files in the source folder.
    Please Login or Register  to view this content.

    Calling the macro
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    03-08-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Search for old files by last accessed from a designated folder

    Hiya Leith

    Thank you so much for this, all works fine until it tries to access the sub folders and the code debugs. Is there anyway that I get last accessed and not modified. Otherwise it gives me exactly what I require.

    If IncludeSubfolders Then
    For Each SubFolder In SourceFolder.SubFolders
    ListFilesInFolder SubFolder.Path, True
    Next SubFolder
    End If

    So impressed with the response, thank you !!!!

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Search for old files by last accessed from a designated folder

    Hello bodiewil,

    I don't know why I used DateLastModified property. Just change that to DateLastAccessed.

    The other problem was a typo. That should read....
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-08-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Search for old files by last accessed from a designated folder

    Pure Genius Leith

    Now to be a pain in the neck what would I have to add to show Filesize.

    Thanks so much for everything

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Search for old files by last accessed from a designated folder

    Hello bodiewil,

    To add the file size ...
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-08-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Search for old files by last accessed from a designated folder

    Thanks Leith just perfect....... Hope to speak to you soon

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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