편집

다음을 통해 공유


Explorer.BeforeItemCopy event (Outlook)

Occurs when an Outlook item is copied.

Syntax

expression. BeforeItemCopy( _Cancel_ )

expression A variable that represents an Explorer object.

Parameters

Name Required/Optional Data type Description
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 copied.

Remarks

This event can be cancelled after it has started.

Example

The following Microsoft Visual Basic for Applications (VBA) example prompts the user before an item is copied. A message is displayed to the user verifying that the item should be copied. If the user clicks Yes, the item is copied to the Clipboard. The sample code must be placed in a class module such as ThisOutlookSession, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Public WithEvents myOlExp As Outlook.Explorer 
 
 
 
Sub Initialize_Handler() 
 
Set myOlExp = Application.ActiveExplorer 
 
End Sub 
 
 
 
Private Sub myOlExp_BeforeItemCopy(Cancel As Boolean) 
 
'Prompts the user before copying an item 
 
 
 
 Dim lngAns As Long 'user answer 
 
 'Display question to user 
 
 lngAns = MsgBox("Are you sure you want to copy the item?", vbYesNo) 
 
 If lngAns = vbYes Then 
 
 Cancel = False 
 
 Else 
 
 'Set Cancel argument based on answer 
 
 Cancel = True 
 
 End If 
 
 
 
End Sub

See also

Explorer Object

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.