1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
Function ExtraitDate(st As String) As Date
'Excel20061512100647.xls
'Debug.Print "Annee : " & Mid(st, 6, 4)
' Debug.Print "Jour : " & Mid(st, 10, 2)
' Debug.Print "Mois : " & Mid(st, 12, 2)
' Debug.Print "Heure : " & Mid(st, 14, 2)
' Debug.Print "Minute : " & Mid(st, 16, 2)
' Debug.Print "Secondes : " & Mid(st, 18, 2)
ExtraitDate = DateSerial(Mid(st, 6, 4), Mid(st, 12, 2), Mid(st, 10, 2)) + TimeSerial(Mid(st, 14, 2), Mid(st, 16, 2), Mid(st, 18, 2))
End Function
Sub ChercheFichier()
Dim st As String
Dim MemoNomFic As String
Dim MemoDateFic As Date
Dim d As Date
st = Dir("c:\tmp\*.xls")
While st <> ""
d = ExtraitDate(st)
If d > MemoDateFic Then
MemoNomFic = st
MemoDateFic = d
End If
st = Dir
Wend
MsgBox MemoNomFic & ".. du " & MemoDateFic
End Sub |
Partager