Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA adding drag and drop functionality to VB form

Status
Not open for further replies.

dprayner

Programmer
Oct 14, 2002
140
US
Hi people. I found this code online in hopes to modifying it for one of my projects. I am using the VB Editor in MS Word 2003 and want to allow the user to drag emails and/or attachments directly into/onto a text box like Outlook has. I included the code below. I was wondering if the Form_DragDrop is a reserved reference or can it be changed to suit the form name you are using. Thank you, DAVE

Option Explicit

Dim rX As Single
Dim rY As Single
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Source.Left = X - rX
Source.Top = Y - rY
End Sub
Private Sub List1_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)

Form_DragDrop Source, List1(Index).Left + X, List2(Index).Top + Y

End Sub
Private Sub List1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
rX = X
rY = Y
List1(Index).Drag
End If
End Sub
Private Sub list2_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)

Form_DragDrop Source, List2(Index).Left + X, List2(Index).Top + Y

End Sub
Private Sub list2_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
rX = X
rY = Y
List2(Index).Drag
End If
End Sub
 
Dave,

Not sure about Word, but in VB6 Drag/Drop events are contained within the form itself. To access the clipboard and make the thing "talk to the ouside world", You enable the OLE_Drag_Drop events... maybe this is your problem.

Like I said, I'm not a Word expert, but it may help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top