BeforeGroupSwitch Event 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