BeforeDropOrPaste Event

Applies To

CheckBox control, ComboBox control, CommandButton control, Frame control, Image control, Label control, ListBox control, MultiPage control, OptionButton control, TabStrip control, TextBox control, ToggleButton control, UserForm object.

Description

Occurs when the user is about to drop or paste data onto an object.

Syntax

For Frame

Private Sub object_BeforeDropOrPaste( ByVal Cancel As
úMSForms.ReturnBoolean, ctrl As Control, ByVal Action As fmAction,
úByVal Data As DataObject, ByVal X As Single, ByVal Y As Single, ByVal Effect As
úMSForms.ReturnEffect, ByVal Shift As fmShiftState)

For MultiPage

Private Sub object_BeforeDropOrPaste( index As Long, ByVal Cancel As
úMSForms.ReturnBoolean, ctrl As Control, ByVal Action As fmAction, ByVal
úData As DataObject, ByVal X As Single, ByVal Y As Single, ByVal Effect As
úMSForms.ReturnEffect, ByVal Shift As fmShiftState)

For TabStrip

Private Sub object_BeforeDropOrPaste( index As Long, ByVal Cancel As
úMSForms.ReturnBoolean, ByVal Action As fmAction, ByVal Data As DataObject,
úByVal X As Single, ByVal Y As Single, ByVal Effect As MSForms.ReturnEffect,
úByVal Shift As fmShiftState)

For other controls

Private Sub object_BeforeDropOrPaste( ByVal Cancel As MSForms.ReturnBoolean,
úByVal Action As fmAction, ByVal Data As DataObject, ByVal X As Single, ByVal
úY As Single, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As fmShiftState)

The BeforeDropOrPaste event syntax has these parts:

Part

Description

object

Required. A valid object name.

index

Required. The index of the Page in a MultiPage that the drop or paste operation will affect.

Cancel

Required. Event status. False indicates that the control should handle the event (default). True indicates the application handles the event.

ctrl

Required. The target control.

Action

Required. Indicates the result, based on the current keyboard settings, of the pending drag-and-drop operation.

Data

Required. Data that is dragged in a drag-and-drop operation. The data is packaged in a DataObject.

X, Y

Required. The horizontal and vertical position of the mouse pointer when the drop occurs. Both coordinates are measured in points. X is measured from the left edge of the control; Y is measured from the top of the control..

Effect

Required. Effect of the drag-and-drop operation on the target control.

Shift

Required. Specifies the state of SHIFT, CTRL, and ALT.


Settings

The settings for Action are:

Constant

Value

Description

fmActionPaste

2

Pastes the selected object into the drop target.

fmActionDragDrop

3

Indicates the user has dragged the object from its source to the drop target and dropped it on the drop target.


The settings for Effect are:

Constant

Value

Description

fmDropEffectNone

0

Does not copy or move the drop source to the drop target.

fmDropEffectCopy

1

Copies the drop source to the drop target.

fmDropEffectMove

2

Moves the drop source to the drop target.

fmDropEffectCopyOrMove

3

Copies or moves the drop source to the drop target.


The settings for Shift are:

Constant

Value

Description

fmShiftMask

1

SHIFT was pressed.

fmCtrlMask

2

CTRL was pressed.

fmAltMask

4

ALT was pressed.


Remarks

For a MultiPage or TabStrip, Visual Basic for Applications initiates this event when it transfers a data object to the control.

For other controls, the system initiates this event immediately prior to the drop or paste operation.

When a control handles this event, you can update the Action argument to identify the drag-and-drop action to perform. When Effect is set to fmDropEffectCopyOrMove, you can assign Action to fmDropEffectNone, fmDropEffectCopy, or fmDropEffectMove. When Effect is set to fmDropEffectCopy or fmDropEffectMove, you can reassign Action to fmDropEffectNone. You cannot reassign Action when Effect is set to fmDropEffectNone.

See Also

BeforeDragOver event, DataObject object.