Bonsoir à tous,
j'ai besoin de vos lumières pour affiner le code que j'ai fait pour afficher les fichiers avec lien hypertexte sur la feuille Excel.
(Source : Forum dont j'adapte selon mes besoins)
Je souhaite que : à chaque fois que je souhaite afficher des fichiers du même dossier, soit la liste continue à afficher (=ajouter) les derniers fichiers créés.
Soit, effacer tous et réaffiche de nouveau les fichiers du début au dernier fichier créés.
Juju
Sub Bouton15_Cliquer()
Dim xFSO As Object
Dim xFolder As Object
Dim xFile As Object
Dim xFiDialog As FileDialog
Dim xPath As String
Dim I As Integer
Set xFiDialog = Application.FileDialog(msoFileDialogFolderPicker)
If xFiDialog.Show = -1 Then
xPath = xFiDialog.SelectedItems(1)
End If
Set xFiDialog = Nothing
If xPath = "" Then Exit Sub
Set xFSO = CreateObject("Scripting.FileSystemObject")
Set xFolder = xFSO.GetFolder(xPath)
For Each xFile In xFolder.Files
I = I + 1
ActiveSheet.Hyperlinks.Add Cells(I + 3, 5), xFile.Path, , , xFile.Name
Next
End Sub