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
| 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
If Files.Count <> 0 Then
Sheets.Add
For Each File In Files
i = i + 1
ActiveSheet.Hyperlinks.Add Anchor:=Cells(i, 1), Address:=File.Path
Next
End If
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 |
Partager