Explorer.BeforeMove 事件 (Outlook)Explorer.BeforeMove Event (Outlook)

当用户移动**Explorer** 时发生。Occurs when the Explorer is moved by the user.

语法Syntax

expressionexpression. BeforeMove( _Cancel_ )

_表达式_一个代表Explorer对象的变量。expression A variable that represents an Explorer object.

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
CancelCancel 必需Required BooleanBoolean 的事件发生时。False when the event occurs. 如果事件过程将此参数设置为True ,则不完成操作和浏览器或检查也不会移动。If the event procedure sets this argument to True , the operation is not completed and the explorer or inspector is not moved.

注解Remarks

该事件在开始后可以取消。This event can be cancelled after it has started.

示例Example

以下 Microsoft Visual Basic for Applications (VBA) 示例在用户移动浏览器前向用户提示一条消息。The following Microsoft Visual Basic for Applications (VBA) example prompts the user with a message before the explorer is moved by the user. 如果用户单击,用户可以移动浏览器。If the user clicks Yes, the explorer can be moved by the user. 示例代码必须放在类模块(如 ThisOutlookSession)中,并且在 Microsoft Outlook 调用该事件过程前应先调用 Initialize_Handler() 子例程。The sample code must be placed in a class module such as ThisOutlookSession, and the Initialize_Handler() subroutine should be called before the event procedure can be called by Microsoft Outlook.

Public WithEvents myOlExp As Outlook.Explorer 
 
 
 
Sub Initalize_Handler() 
 
 Set myOlExp = Application.ActiveExplorer 
 
End Sub 
 
 
 
Private Sub myOlExp_BeforeMove(Cancel As Boolean) 
 
'Prompts the user before moving the window 
 
 
 
 Dim lngAns As Long 
 
 
 
 lngAns = MsgBox("Are you sure you want to move the current window? Use your keyboard to make your selection.", vbYesNo) 
 
 If lngAns = vbYes Then 
 
 Cancel = False 
 
 Else 
 
 Cancel = True 
 
 End If 
 
 
 
End Sub

另请参阅See also

资源管理器对象Explorer Object