BeforeItemCut Event

Microsoft Outlook Visual Basic

BeforeItemCut Event

       

Occurs when an item is cut from a folder. This method can be cancelled after it has started. If the event is cancelled, then the item will not be removed.

Private Sub explorer_BeforeItemCut(Cancel As Boolean)

explorer   An expression that returns an Explorer object.

Cancel   Optional. 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 with a warning message before the item is cut from the folder. If the user clicks Yes, the item is cut from the folder. If the user clicks No, the item will not be removed from the folder.

Private Sub objExplorer_BeforeItemCut(Cancel As Boolean)
'prompts the user before cutting an item

   Dim lngAns As Long 'user answer
   'Display question to user
   lngAns = MsgBox("Are you sure you want to cut the item?", vbYesNo)
   'Set cancel argument based on answer
   If lngAns = vbYes Then
       Cancel = False
   ElseIf lngAns = vbNo Then
       Cancel = True
   End If

End Sub