BeforeGroupSwitch Event

Microsoft Outlook Visual Basic

Show All

BeforeGroupSwitch Event

       

Occurs before a new group is opened in the Outlook Bar, either as a result of user action or through program code. This event is not available in VBScript.

Sub object_BeforeGroupSwitch(ByVal ToGroup As OutlookBarGroup, Cancel as Boolean)

object   An expression that evaluates to an OutlookBarPane object.

ToGroup   Required. The OutlookBarGroup being opened.

Cancel   Optional. False when the event occurs. If the event procedure sets this argument to True, the change is cancelled and the current group remains open.

Example

This example prevents the user from opening the Outlook Bar group named Other Shortcuts. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Public WithEvents myOlPane As Outlook.OutlookBarPane

Public Sub Initialize_handler()
    Set myOlPane = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
End Sub

Private Sub myOlPane_BeforeGroupSwitch(ByVal ToGroup As Outlook.OutlookBarGroup, Cancel As Boolean)
    If ToGroup.Name = "Other Shortcuts" Then Cancel = True
End Sub