How to get the newest zip file in a given folder

b3cf
b3cf used Ask the Experts™
on
Hi

  Could someone advice me on how I could get the
newest zip file name in a given folder. Some code
will be very helpfull.

Any help is greatly appreciated.

Thanx
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Of course you will need to change MyPath
   
    Dim MyFile As String
    Dim MyPath As String
    Dim MyName As String
    Dim LatestFileDate As Date
    MyPath = "C:\"
    MyFile = Dir(MyPath & "*.zip")


    Do Until MyFile = ""
   
        If FileDateTime(MyPath & MyFile) > LatestFileDate Then
            LatestFileDate = FileDateTime(MyPath & MyFile)
            MyName = MyPath & MyFile
        End If
        MyFile = Dir
       
    Loop
    MsgBox "Latest File = " & MyName & vbCrLf & "Date = " & LatestFileDate
    ' Call Dir again without arguments to return the next *.INI file in the
    ' same directory.
   


Author

Commented:
Thanx buddy...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial