BeforeMaximize Event

Explorer.BeforeMaximize Event (Outlook)

Office 2013 and later
GitHub-Mark-64px

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Occurs when an explorer is maximized by the user.

expression .BeforeMaximize(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 explorer is not maximized.

This event can be cancelled after it has started.

The following Microsoft Visual Basic for Applications (VBA) example prompts the user with a warning message before maximizing the current window. If the user clicks Yes, the explorer will maximize. 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_BeforeMaximize(Cancel As Boolean) 
 
'Prompts the user before maximizing the explorer 
 
 
 
 Dim lngAns As Long 
 
 
 
 lngAns = MsgBox("Are you sure you want to maximize the current window?", vbYesNo) 
 
 If lngAns = vbYes Then 
 
 Cancel = False 
 
 Else 
 
 Cancel = True 
 
 End If 
 
 
 
End Sub 
 
 
 

Show:
© 2016 Microsoft