Bonjour, Dans le code ci-dessous (code repris sur le site de JP Boisgontier), j'aimerais pouvoir cliquer sur une ligne de la listbox pour ouvrir le fichier en relation. Comment faire ? merci.
Code:
Private Sub Ext_Change() If Me.TextBox1 "" Then affiche End If End Sub Private Sub UserForm_Initialize() Me.Ext.List = Array("*.*", "XLS", "DOC", "MDB", "HTM", "ZIP", "JPG", "GIF") Me.Ext.ListIndex = 0 End Sub Private Sub CommandButton1_Click() racine = ChoixDossier() If racine = "" Then Exit Sub Set fs = CreateObject("Scripting.FileSystemObject") Set dossier = fs.getfolder(racine) Me.TextBox1 = racine affiche End Sub Sub affiche() i = 0 Me.ListBox1.Clear For Each f In dossier.Files If Me.Ext = "*.*" Or UCase(Right(f.Name, 3)) = Me.Ext Then Me.ListBox1.AddItem Me.ListBox1.List(i, 0) = f.Name Me.ListBox1.List(i, 1) = String(10 - Len(f.Size), " ") & f.Size Me.ListBox1.List(i, 2) = Format(f.Datecreated, "dd/mm/yy") Me.ListBox1.List(i, 3) = Format(f.DatelastModified, "dd/mm/yy") i = i + 1 End If Next Me.TextBox2 = Me.ListBox1.ListCount End Sub Function ChoixDossier() If Val(Application.Version) >= 10 Then With Application.FileDialog(msoFileDialogFolderPicker) .InitialFileName = ActiveWorkbook.Path & "C:\Users\jean" .Show If .SelectedItems.Count > 0 Then ChoixDossier = .SelectedItems(1) Else ChoixDossier = "" End If End With Else ChoixDossier = InputBox("Répertoire?") End If End Function