View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Locate Most Recent File

maybe not clever but it works..

Sub mrf()
Dim szFile(1) As String
Dim dtFile(1) As Date

szFile(0) = Dir("*.xls")

While Not szFile(0) = vbNullString
dtFile(0) = VBA.FileDateTime(szFile(0))
If dtFile(0) dtFile(1) Then
dtFile(1) = dtFile(0)
szFile(1) = szFile(0)
End If
szFile(0) = Dir()
Wend

MsgBox szFile(1) & " timestamp " & dtFile(1)

End Sub


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


andibevan wrote:


Hi All,

I need to be able to locate the most recent file within a specified
directory so that I can use it for other parts of my code.

Does anyone have any clever ideas on how you can do this?

Thanks

Andy

;)