共用方式為


Explorer.BeforeItemCut 事件 (Outlook)

當從資料夾剪下 Outlook 項目時會發此事件。

語法

expressionBeforeItemCut( _Cancel_ )

表達 代表 Explorer 物件的 變數。

參數

名稱 必要/選用 資料類型 描述
Cancel 必要 布林值 False 事件發生時。 如果事件程序將此引數設定為 True,則無法完成作業,而且無法刪除項目。

註解

在啟動此物件之後可以將它取消。 如果取消事件,則不會移除專案。

範例

下列 Microsoft Visual Basic for Applications (VBA) 範例會在從資料夾剪下專案之前,向使用者提示警告訊息。 如果使用者按一下 [ ],就會從資料夾剪下專案。 如果使用者按一下 [ ],專案將不會從資料夾中移除。 範例程式碼必須放在類別模組中,例如 ThisOutlookSession ,而且 Initialize_handler 必須先呼叫常式,Microsoft Outlook 才能呼叫事件程序。

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

另請參閱

Explorer 物件

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應