Re : Modif de macro lister Fichier
bonjour Bqtr
Géraldine essaye ce code,tu choisis un dossier
Sub TousFichiersDunDossier()
Dim fso As Object, Dossier As Object, NomDossier
Dim Files As Object, File As Object, i As Integer
Set fso = CreateObject("Scripting.FileSystemObject")
NomDossier = ChoisirDossier
If NomDossier = "" Then Exit Sub
Set Dossier = fso.getfolder(NomDossier)
Set Files = Dossier.Files
Sheets("Feuil2").Cells.Clear
If Files.Count <> 0 Then
With Sheets("Feuil2")
For Each File In Files
If Right(File.Name, 4) = ".xls" Then
i = i + 1
.Cells(i, 1).Value = File.Path
.Hyperlinks.Add Anchor:=Cells(i, 1), Address:=File.Path
End If
Next File
End With
End If
Sheets("Feuil2").Columns("A").AutoFit
End Sub
Function ChoisirDossier()
Dim objShell, objFolder, chemin, SecuriteSlash
Set objShell = CreateObject("Shell.Application")
Set objFolder = _
objShell.BrowseForFolder(&H0&, "Choisisser un répertoire", &H1&)
On Error Resume Next
chemin = objFolder.ParentFolder.ParseName(objFolder.Title).Path & ""
If objFolder.Title = "Bureau" Then
chemin = "C:\Windows\Bureau"
End If
If objFolder.Title = "" Then
chemin = ""
End If
SecuriteSlash = InStr(objFolder.Title, ":")
If SecuriteSlash > 0 Then
chemin = Mid(objFolder.Title, SecuriteSlash - 1, 2) & ""
End If
ChoisirDossier = chemin
End Function
à bientôt