BeforeItemPaste Event
Occurs when a Microsoft Outlook item is pasted. This event can be cancelled after it has started.
Private Sub expression_BeforeItemPaste(ClipboardContent As Variant, ByVal Target As MAPIFolder, Cancel As Boolean)
expression An expression that returns an Explorer object declared with events in a class module.
ClipboardContent Required Variant. The content to be pasted.
Target Required MAPIFolder. The destination of the paste.
Cancel Required Boolean. False when the event occurs. If the event procedure sets this argument to True, the operation is not completed and the item is not deleted.
Example
The following example prompts the user before pasting the contents of the Clipboard to the specified target. If the user clicks Yes, the contents of the Clipboard are copied to the specified target destination and a message box is displayed for each item copied.
Private Sub objExplorer_BeforeItemPaste(ClipboardContent As Variant, ByVal Target As MAPIFolder, Cancel As Boolean)
Dim lngAns As Integer 'users' answer
'Prompt user about paste
lngAns = MsgBox("Are you sure you want to past the contents of the clipboard into the " _
& Target.Name & "?", vbYesNo)
If lngAns = vbYes Then
'If user wants to paste
If TypeOf ClipboardContent Is Selection Then
'if is collection, display each object name
Dim obj As Object
For Each obj In ClipboardContent
'Display subject of item
MsgBox "Pasting Item: " & obj.Subject
'Next Item
Next
End If
Cancel = False
Else
'If user clicks no, display message and cancel paste
MsgBox "The clipboard content was not pasted."
Cancel = True
End If
End Sub