VBA question accessing other files...

GHoosdumGHoosdum Icrontian
edited May 2005 in Internet & Media
I'm trying to find out if it's possible in VBA to determine the last updated date of a file. I need to read in 3 files in a VBA program to pull information into a spreadsheet, but only if they were updated on the current day. Any pointers?

Comments

  • EMTEMT Seattle, WA Icrontian
    edited May 2005
    Well if you had to you could process a dir command's output right? But there's probably an easier way (I only know Basic, nothin visual).
  • GargGarg Purveyor of Lincoln Nightmares Icrontian
    edited May 2005
    Haven't tried it, but this is what I came up with in the VBA help:
    FileDateTime(pathname)

    The required pathname argument is a string expression that specifies a file name. The pathname may include the directory or folder, and the drive.

    I suppose you could do a mathematical operation to subtract it from the current date/time to see if it's the same day, since it returns more than just the date.

    example from VBA help:
    FileDateTime Function Example
    This example uses the FileDateTime function to determine the date and time a file was created or last modified. The format of the date and time displayed is based on the locale settings of your system.

    Dim MyStamp
    ' Assume TESTFILE was last modified on February 12, 1993 at 4:35:47 PM.
    ' Assume English/U.S. locale settings.
    MyStamp = FileDateTime("TESTFILE") ' Returns "2/12/93 4:35:47 PM".
Sign In or Register to comment.