listbox et ouverture fichier sur clic

  • Initiateur de la discussion Initiateur de la discussion jopont
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

jopont

XLDnaute Impliqué
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
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
10
Affichages
303
Réponses
3
Affichages
677
  • Question Question
Microsoft 365 Problème de date
Réponses
5
Affichages
173
Réponses
4
Affichages
507
  • Question Question
Microsoft 365 worksheet_change
Réponses
29
Affichages
544
Retour