When you get the dragged file name, pass it to a procedure to open it and read its contents and put inside the listbox.
Try this
Code:Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single) Dim j As Long If Data.GetFormat(vbCFFiles) = True Then If Not (GetAttr(Data.Files.Item(1)) And vbDirectory) Then ' To open only one file OpenFile(Data.Files.Item(1)) ' To open multi files 'For j = 1 To Data.Files.Count ' OpenFile(Data.Files.Item(j)) ' MsgBox Data.Files.Item(j) 'Next End If End If End Sub Private Sub OpenFile(ByVal strFile As String) Dim intFN As Integer Dim strIN As String On Error GoTo errIOError intFN = FreeFile Open strFile For Input As #intFN Do While Not EOF(intFN) Line Input #intFN, strIN strIN = Trim$(strIN) If LenB(strIN) <> 0 Then List1.AddItem strIN End If Loop Close #intFN Exit Sub errIOError: Close #intFN End Sub





Reply With Quote