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 32 33 34 35 36 37 38 39 40 41 42 43 44
| Sub RechercherFichiers() 'recherche des fichiers
Dim MonRepertoire As String, Lr As Byte, fso As Object, fs As FileSearch
Dim montableau(), i As Integer, j As Integer, k As Integer, temp
Set fso = CreateObject("Scripting.FileSystemObject")
Set fs = Application.FileSearch
MonRepertoire = "C:\Documents and settings\Chewi\FichiersExcel"
With fs
.LookIn = MonRepertoire
.Filename = "*.xls"
If .Execute > 0 Then
ReDim montableau(1 To .FoundFiles.Count, 1 To 2)
For i = 1 To .FoundFiles.Count
montableau(i, 1) = .FoundFiles(i)
montableau(i, 2) = fso.GetFile(.FoundFiles(i)).DateLastModified
Next i
End If
End With
If fs.FoundFiles.Count < 1 Then Exit Sub 'précautions sinon erreur dans la boucle
'quand égal à 0
For i = LBound(montableau) To UBound(montableau)
For j = LBound(montableau) To UBound(montableau)
If montableau(i, 2) > montableau(j, 2) Then
For k = LBound(montableau, 2) To UBound(montableau, 2)
temp = montableau(i, k)
montableau(i, k) = montableau(j, k)
montableau(j, k) = temp
Next k
End If
Next j
Next i
For i = 1 To fs.FoundFiles.Count 'précaution si égal à 0 plus haut
'Cells(i, 1).Value =
UfCompleter.ComboBox1.AddItem Left(Right(montableau(i, 1), 34), 30)
'Cells(i, 2).Value = montableau(i, 2)
If i = 7 Then Exit For
Next i
End Sub |
Partager