Add (OlapMenuItems)
The Add method of the OlapMenuItems collection adds a new OlapMenuItem object to the collection. It returns an object of type OlapMenuItem.
Syntax
Set vnt = object.Add(MenuType As OlapMenuTypes, [Caption As String], [Key As Long], [ParentKey As Long], [Flags As OlapMenuFlags])
vnt
An instance of OlapMenuItem that receives the instance of the new member.
object
An instance of the OlapMenuItems collection.
MenuType
A constant from the OlapMenuTypes enumeration.
Caption
The string value to be displayed in the menu.
Key
User-defined key value to be used by the add-in.
ParentKey
Associates a child menu item with its parent. Used when the parent menu item is defined using the mnuflagPopup option in MenuType.
Flags
A bitmask of values from the OlapMenuFlags enumeration.
Remarks
The Add method is used to populate the OlapMenuItems collection with menu items to be displayed when the user right-clicks a tree node. Call this method for each menu item you want to add.
Example
The following example builds a menu with various menu items:
Private Enum MenuActions
mnuActTop
mnuActMid
mnuActBtm
mnuActSpc
End Enum
Private Sub IOlapAddIn_ProvideMenuItems(CurrentNode As DSSAddInsManager.OlapTreeNode, MenuItems As DSSAddInsManager.OlapMenuItems)
On Error GoTo ProvideMenuItems_Err 'Handle errors
If CurrentNode.Caption = "Node 1" Then
'Enable default New menu item and add child menu items
MenuItems.Add mnuStandard, "&Top", mnuActTop, , mnuflagNew
MenuItems.Add mnuStandard, "&Mid", mnuActMid, , mnuflagNew
MenuItems.Add mnuStandard, "&Btm", mnuActBtm, , mnuflagNew
'Add regular menu item to root menu
MenuItems.Add mnuStandard, "&Special", mnuActSpc, , mnuflagRegular
End If
Exit Sub
ProvideMenuItems_Err:
MsgBox "ProvideIcon failed"
Err.Clear
End Sub