BeforeGroupRemove Event

Microsoft Outlook Visual Basic

Show All

BeforeGroupRemove Event

       

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

Sub object_BeforeGroupRemove(ByVal Group As OutlookBarGroup, Cancel As Boolean)

object   An expression that evaluates to an OutlookBarGroups collection object.

Group   Required. The OutlookBarGroup that is being removed.

Cancel   Optional. False when the event occurs. If the event procedure sets this argument to True, the group is not removed from the Outlook Bar.

Example

This example prevents the user from removing a group from the Outlook Bar. 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
Dim WithEvents myOlGroups As Outlook.OutlookBarGroups
Dim myOlBar As Outlook.OutlookBarPane

Sub Initialize_handler()
    Set myOlBar = myOlApp.ActiveExplorer.Panes.item("OutlookBar")
    Set myOlGroups = myOlBar.Contents.Groups
End Sub

Private Sub myOlGroups_BeforeGroupRemove(ByVal Group As OutlookBarGroup, Cancel As Boolean)
    Cancel = True
End Sub