BeforeDragOver event

Occurs when a drag-and-drop operation is in progress.

Syntax

For Frame
Private Subobject _BeforeDragOver( ByValCancelAs MSForms.ReturnBoolean,
ctrlAs Control,
ByValDataAs DataObject,
ByValXAs Single,
ByValYAs Single,
ByValDragStateAs fmDragState,
ByValEffectAs MSForms.ReturnEffect,
ByValShiftAs fmShiftState)

For MultiPage
Private Subobject _BeforeDragOver(indexAs Long,
ByValCancelAs MSForms.ReturnBoolean,
ctrlAs Control,
ByValDataAs DataObject,
ByValXAs Single,
ByValYAs Single,
ByValDragStateAs fmDragState,
ByValEffectAs MSForms.ReturnEffect,
ByValShiftAs fmShiftState)

For TabStrip
Private Subobject _BeforeDragOver(indexAs Long,
ByValCancelAs MSForms.ReturnBoolean,
ByValDataAs DataObject,
ByValXAs Single,
ByValYAs Single,
ByValDragStateAs fmDragState,
ByValEffectAs MSForms.ReturnEffect,
ByValShiftAs fmShiftState)

For other controls
Private Subobject _BeforeDragOver( ByValCancelAs MSForms.ReturnBoolean,
ByValDataAs DataObject,
ByValXAs Single,
ByValYAs Single,
ByValDragStateAs fmDragState,
ByValEffectAs MSForms.ReturnEffect,
ByValShiftAs fmShiftState)

The BeforeDragOver 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 drag-and-drop 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 control being dragged over.
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 coordinates of the control's position. 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..
DragState Required. Transition state of the data being dragged.
Effect Required. Operations supported by the drop source.
Shift Required. Specifies the state of SHIFT, CTRL, and ALT.

Settings

The settings for DragState are:

Constant Value Description
fmDragStateEnter 0 Mouse pointer is within range of a target.
fmDragStateLeave 1 Mouse pointer is outside the range of a target.
fmDragStateOver 2 Mouse pointer is at a new position, but remains within range of the same 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

Use this event to monitor the mouse pointer as it enters, leaves, or rests directly over a valid target. When a drag-and-drop operation is in progress, the system initiates this event when the user moves the mouse, or presses or releases the mouse button or buttons. The mouse pointer position determines the target object that receives this event. You can determine the state of the mouse pointer by examining the DragState argument.

When a control handles this event, you can use the Effect argument to identify the drag-and-drop action to perform.

When Effect is set to fmDropEffectCopyOrMove, the drop source supports a copy (fmDropEffectCopy), move (fmDropEffectMove), or a cancel (fmDropEffectNone) operation.

When Effect is set to fmDropEffectCopy, the drop source supports a copy or a cancel (fmDropEffectNone) operation.

When Effect is set to fmDropEffectMove, the drop source supports a move or a cancel (fmDropEffectNone) operation.

When Effect is set to fmDropEffectNone, the drop source supports a cancel operation.

Most controls don't support drag-and-drop while Cancel is False, which is the default setting. This means that the control rejects attempts to drag or drop anything on the control, and the control does not initiate the BeforeDropOrPaste event. The TextBox and ComboBox controls are exceptions to this; these controls support drag-and-drop operations even when Cancel is False.

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.