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
| Sub ListPics()
Dim FoundFile As Variant, r As ADODB.Recordset, p As Integer
Dim RetVal As Long
Application.FileSearch.NewSearch
Application.FileSearch.FileName = "*.gif;*.jpg;*.jpeg"
Application.FileSearch.LookIn = "D:\" ' chemin de recherche
Application.FileSearch.SearchSubFolders = True
RetVal = Application.FileSearch.Execute()
If Application.FileSearch.FoundFiles.Count > 0 Then
CurrentProject.Connection.Execute "DELETE FROM ListeImages"
Set r = New ADODB.Recordset
r.CursorLocation = adUseServer
r.Open "ListeImages", CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdTable
For Each FoundFile In Application.FileSearch.FoundFiles
r.AddNew
p = InStrRev(FoundFile, "\")
If p > 0 Then
r!Chemin = Left(FoundFile, p - 1)
r!Fichier = Mid(FoundFile, p + 1, Len(FoundFile) - p)
Else
End If
Next
If r.EditMode <> adEditNone Then r.Update
r.Close
Set r = Nothing
End If
End Sub |
Partager