Outlook BarPane Events

You can use cancelable Outlook Bar events to prevent navigation from Outlook Bar groups or shortcuts. (For a detailed discussion of the properties and methods of the OutlookBarPane, OutlookBarStorage, OutlookBarGroup, and OutlookBarShortcut objects, see Chapter 11. "Using Visual Basic, VBA, or VBScript with Outlook.") If you dimension the correct object variables using the WithEvents keyword, your code can raise events when Outlook Bar groups and shortcuts are added to or removed from the Outlook Bar.

If you raise events on Outlook Bar panes, groups, and shortcuts, you'll need to instantiate object variables during event procedures for other objects in the Outlook Object Model. The table below suggests event procedures where you should set a reference to the object variable.


Set Object Reference in This Event Procedure








The BeforeGroupSwitch event occurs before Outlook switches to a different Outlook Bar group, either because of user action or a programmatic change. Because this event is cancelable, you can prevent users from changing to a prohibited group on the Outlook Bar. The following example instantiates a collection object for OutlookBarShortcuts and then prevents the user from switching to the Real Estate Division group on the Outlook Bar:

Private Sub objPane_BeforeGroupSwitch(ByVal ToGroup As OutlookBarGroup, _ Cancel As Boolean) Set colOutlookBarShortcuts = ToGroup.Shortcuts If ToGroup = "Real Estate Division" Then

MsgBox "You cannot switch to " & ToGroup.Name _

& " on the Outlook Bar!", vblnformation Cancel = True End If End Sub


The BeforeNavigate event occurs before Outlook navigates to a folder or launches an Outlook Bar shortcut, either because of user action or program code. Because this event is cancelable, you can prevent users from navigating to folders or launching shortcut URLs or executables.

Private Sub objPane_BeforeNavigate(ByVal Shortcut As OutlookBarShortcut, _ Cancel As Boolean) If Shortcut.Name = "Financial Services" Then

Cancel = True End If End Sub

Was this article helpful?

0 0

Post a comment