Function to Find the Latest File
Sub Exec_Get_Latest_File()
File1 = "c:\temp\Sample.txt"
File2 = "c:\temp\Sample1.txt"
MsgBox "The LatestFile is " & Get_Latest_File(File1, File2)
End Sub
Function Get_Latest_File(ByVal sFile1 As String, ByVal sFile2 As String) As String
Dim DateFile1 As Date
Dim DateFile2 As Date
DateFile1 = FileDateTime(sFile1)
DateFile2 = FileDateTime(sFile2)
If DateDiff("s", DateFile1, DateFile2) = 0 Then
Get_Latest_File = "Both Files are Modified at the same time"
ElseIf DateDiff("s", DateFile1, DateFile2) <>
Get_Latest_File = sFile1
Else
Get_Latest_File = sFile2
End If
End Function
Friday, May 04, 2007
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.
ElseIf DateDiff("s", DateFile1, DateFile2) <>
ReplyDeleteShould be
ElseIf DateDiff("s", DateFile1, DateFile2) < 0 then