merci defluc, c'est bien cela que je veux faire avec la fonction récursive.
J'ai trouve cela :
http://warin.developpez.com/access/fichiers/
avec le code suivant :
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
| Option Explicit
Sub Explorer(p_strFichier As String, p_strCheminDepart As String, Optional p_oFld As Scripting.Folder)
'On Error GoTo err
Dim oFSO As Scripting.FileSystemObject
Dim oFld As Scripting.Folder
Dim oFl As File
If p_oFld Is Nothing Then
'Instanciation du FSO (déclare l'objet FSO (gestion des dossiers et fichiers))
Set oFSO = New Scripting.FileSystemObject
'Accède au répertoire du départ de recherche
Set p_oFld = oFSO.GetFolder(p_strCheminDepart)
End If
Set oFl = p_oFld.Files(p_strFichier)
MsgBox oFl.Path
SubDir:
'Explore les sous-dossiers
For Each oFld In p_oFld.SubFolders
Explorer p_strFichier, p_strCheminDepart, oFld
DoEvents
Next oFld
fin:
Exit Sub
err:
Select Case err.Number
Case 53: Resume SubDir
Case Else:
MsgBox "Erreur inconnue"
Resume fin
End Select
End Sub |
problème, quand j'execute la macro j'ai un "type défini par l'utilisateur non définir" sur la ligne :
Sub Explorer(p_strFichier As String, p_strCheminDepart As String, Optional p_oFld As Scripting.Folder)
Partager