Hi All
How do I drag a file onto a text box and display the files path and name in the text box.
Cheers
Printable View
Hi All
How do I drag a file onto a text box and display the files path and name in the text box.
Cheers
Set the OLEDropMode property of the TextBox to 1 Manual, then use this:
This will allow you to drag multiple files as well.Code:Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim varFiles As Variant
On Error Resume Next
For Each varFiles In Data.Files
Text1.Text = Text1.Text & varFiles & vbCrLf
Next
End Sub
Thanks Serge
That works fine but leaves two characters at the end
Code:C:\WINNT\Profiles\loweg\Desktop\test.lf
Serge
It doesn't disply them on the previous post but it leaves two bold lines on the end.
Do you know anyway to stop this?
Thanks
Set the OLEDropMode to Manual and the MultiLine property on the text box to TRUE, and try this....
Code:Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Data.Files.Count > 0 Then
For z = 1 To Data.Files.Count
Text1.Text = Text1.Text + Data.Files(z) + vbNewLine
Next z
End If
End Sub
Thanks joefoulkes
works fine now