共用方式為


GroupAdd Event

Occurs when a new group has been added to the Shortcuts pane. This event is not available in Microsoft Visual Basic Scripting Edition (VBScript).

Subobject**_GroupAdd(ByVal NewGroup As OutlookBarGroup)**

*object   * An expression that evaluates to an OutlookBarGroups object.

*NewGroup   * Required. The OutlookBarGroup that was added.

Example

This Microsoft Visual Basic/Visual Basic for Applications (VBA) example adds a shortcut to the Calendar whenever a group is created. 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_GroupAdd(ByVal NewGroup As Outlook.OutlookBarGroup)
    Dim myFolder As Outlook.MAPIFolder
    Set myFolder = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar)
    NewGroup.Shortcuts.Add myFolder, "Calendar"
End Sub

Applies to | OutlookBarGroups Object

See Also | Add Method | BeforeGroupAdd Event | BeforeGroupRemove Event | OutlookBarGroup Object | Using events with Automation