+ Reply to Thread
Results 1 to 2 of 2

How to pick the right file

  1. #1
    Ben
    Guest

    How to pick the right file

    Hi all,

    I have a series of Excel files in a directory out in the network. The file
    names are suffixed by a date stamp as in: "_mm-dd-yyy.xls". I need to open
    the latest file. But the latest file can be older than the date in the
    system's clock. For example, it can be Monday today and the latest file is
    from previous week's Friday. I was thinking of using a array or file system
    object to read in all the files and truncate the date portion and compare
    them. But that seems me a very ineffective and inefficient way of doing
    thing. Can you share your thoughts or code snipppets? Thanks.

    Ben

    --

    --


  2. #2
    Tom Ogilvy
    Guest

    RE: How to pick the right file

    If it will always be withing a couple of days

    Dim dt as Date
    dt = Date
    do while dir("C:\Myfolder\*_" & format(dt,"mm-dd-yyyy.xls") = ""
    dt = dt - 1
    if dt < Date - 5 then
    msgbox "Problems"
    exit sub
    end if
    Loop
    --
    Regards,
    Tom Ogilvy




    "Ben" wrote:

    > Hi all,
    >
    > I have a series of Excel files in a directory out in the network. The file
    > names are suffixed by a date stamp as in: "_mm-dd-yyy.xls". I need to open
    > the latest file. But the latest file can be older than the date in the
    > system's clock. For example, it can be Monday today and the latest file is
    > from previous week's Friday. I was thinking of using a array or file system
    > object to read in all the files and truncate the date portion and compare
    > them. But that seems me a very ineffective and inefficient way of doing
    > thing. Can you share your thoughts or code snipppets? Thanks.
    >
    > Ben
    >
    > --
    >
    > --
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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