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

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


expressionexpression. BeforeMove( _Cancel_ )

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


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
CancelCancel 必需Required BooleanBoolean 如果发生事件,则为 FalseFalse 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.


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


以下 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 Initialize_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 
 Cancel = True 
 End If 
End Sub

另请参阅See also

资源管理器对象Explorer Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.