Reflection Desktop VBA Guide
Attachmate.Reflection.Objects.Emulation.IbmHosts Library / Attachmate.Reflection.Objects.Emulation.IbmHosts Library / ContextMenus Object / Add Method
Example
In This Topic
    Add Method (ContextMenus)
    In This Topic
    Adds (or updates an existing) context menu to this session document
    Syntax
    expression.Add( _
       ByVal menu As ContextMenu _
    ) As Boolean
    where expression is a variable that represents a ContextMenus Object

    Parameters

    menu
    The context menu to add This is a ContextMenu Object that contains the context menu to add.

    Return Value

    True if the add or update was successful, false if an error occurred
    Exceptions
    ExceptionDescription
    If the name passed is null or empty
    If the ContextMenus object is not available or in an error state
    Example
    This example adds menu item to default context menu and uses the Add method to update the menu.
    Sub AddMenuToDefaultMenuFix()
     
        Dim action As InputMapAction
        Dim sequence As InputMapActionSequence
        Dim menuItem As ContextMenuItem
        
        Dim menu As contextMenu
       
        'Get the default context menu.
        Set menu = ThisIbmTerminal.ContextMenus.ItemByName("Default")
     
        'Create an action sequence to hold the actions.
        Set sequence = New InputMapActionSequence
          
        'set an action to open the Office Tools Pane and add it to the sequence.
        Set action = New InputMapAction
        action.ActionId = InputMapActionID_OfficeToolsPaneAction
        sequence.Add action
        
        'Create the menu item for the Office Tools action and map it to the sequence.
        Set menuItem = New ContextMenuItem
        menuItem.Name = "Open Office Tools"
        menuItem.MenuItemType = ContextMenuItemType_MenuItem
        Set menuItem.mapping = sequence
       
        'Add the Office Tools menu item to the menu.
        menu.AddMenuItem menuItem
        
        'Update the menu
        ThisIbmTerminal.ContextMenus.Add menu
     
    End Sub
    See Also