Results 1 to 2 of 2
  1. #1
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Silicon Valley, USA
    Thanked 94 Times in 90 Posts

    Re: Finding files modified after a certain date/time (VBA Word 2000)

    Take a look at the FileSystemObject, which is part of the Scripting library. In particular, you can iterate over a collection of File objects in a Folder and inspect this property: DateLastModified.


    <pre>Sub ListRecentFiles()
    'Requires a reference to the Microsoft Scripting Runtime object lib
    Dim oFS As New FileSystemObject, oFile As File
    'Following not intended to be efficient for large collections of files
    For Each oFile In oFS.GetFolder("c:testfolder").Files
    'List all files less than 2 months old
    If oFile.DateLastModified > DateAdd("m", -2, Now) Then
    ActiveDocument.Range.InsertAfter oFile.Name & " [" & _
    oFile.DateLastModified & "]" & vbCrLf
    End If
    End Sub</pre>

    This sample is to be hosted in a Word module. Hope this helps.

  2. #2
    4 Star Lounger
    Join Date
    Apr 2001
    Thanked 0 Times in 0 Posts

    Finding files modified after a certain date/time (VBA Word 2000)

    Don't know if it is possible to do this or not. I want to create a macro to search all files in a directory for files modified after a specific date and time. I want to be able to input the date and time, perhaps using InputBox, but I can hard code it if necessary. I can hard code the directory as well.

    I saw the LastModified object, but it doesn't seem to allow for specifying a date and/or time. I played around with text I saw here:

    which is a great starting point, but I just can't figure out how to do date and time.

    If I can get it to work, I want to take each of the files returned and put the full path/file name in a word document.

    I'd appreciate any help you can give!!

    Edited to include Hyperlink - Andrew Cronnolly

Posting Permissions

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