Dim repertoire$, Tb$()
Private Sub CbCopier_Click()
If ListBox2.ListIndex = -1 Then MsgBox "Une ligne doit être sélectionnée dans ListBox2...": Exit Sub
With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") ' DataObject en late binding
.SetText ListBox2
.PutInClipboard
End With
[D3].Select
ActiveSheet.Paste 'pour tester, colle le contenu du presse-papiers en D3
End Sub
Private Sub TextBox1_Change()
If Tb(0) <> "" Then ListBox1.List = Filter(Tb, TextBox1, True, vbTextCompare)
End Sub
Private Sub UserForm_Initialize() 'Sylvanu
Dim MyFile$, n&
repertoire = ThisWorkbook.Path & "\1MesMacros\"
MyFile = Dir(repertoire)
ListBox1.Clear
ReDim Tb(0)
While MyFile <> ""
If InStr("/.bas/.txt/.cls/.frm/", "/" & Right(MyFile, 4) & "/") Then
ReDim Preserve Tb(n)
Tb(n) = MyFile
n = n + 1
End If
MyFile = Dir
Wend
If n Then ListBox1.List = Tb
End Sub
Private Sub ListBox1_Click()
Dim IdFile%, TextLine$, a$(), n&
ListBox2.Clear
IdFile = FreeFile
Open repertoire & "\" & ListBox1 For Input As #IdFile
While Not EOF(IdFile)
Line Input #IdFile, TextLine
ReDim Preserve a(n): a(n) = TextLine: n = n + 1
Wend
If n Then ListBox2.List = a
Close #IdFile
End Sub