Reflection Desktop VBA Guide
Attachmate.Reflection.Objects Library / Attachmate.Reflection.Objects.UserInterface Library / UiMode Object / GetControlById Method
ID of the item to retrieve
Example
In This Topic
    GetControlById Method (UiMode)
    In This Topic
    Returns the first control that has the specified ID. Searches the current child items as well as all descendents.
    Syntax
    expression.GetControlById( _
       ByVal id As String _
    ) As UiControl object 
    where expression is a variable that represents a UiMode Object

    Parameters

    id
    ID of the item to retrieve

    Return Value

    Returns the UiControl control if it exists as a descendent of the current control. If not, returns null.
    Example

    This example maps a macro to a button control that was added in the UI designer.


    To run this example, use the UI Designer to create a button control and note the button ID. Then edit the code below to use that ID.

    Sub MapActionToControl()
     
        Dim sequence As InputMapActionSequence
        Dim action As InputMapAction
        Dim control As UiControl
     
        Dim ui As UiMode
     
        'Set an InputMapActionSequence to map the button to.
        Set sequence = New InputMapActionSequence
        
        'Set an action to add to the sequence.
        Set action = New InputMapAction
                             
        'Set the action to run a macro named GetReport.
        action.ActionId = InputMapActionID_RunMacroAction
        
        action.AddParameter "Module1.GetReport" 'Set the name of the macro.
     
        action.AddParameterAsInteger MacroEnumerationOption_Document 'Look for the macro in this Session project.
           
        action.AddParameterAsBoolean False 'Don't ask for any input at runtime.
     
        'Add the action to the action sequence
        sequence.Add action
        
        'Get the control from the control ID. You'll need to get this value from the UI Designer. In this example, the control ID is "button7"
        
        'Edit this line to use the ID of your button.
        Set control = ThisView.UiMode.GetControlById("button7")
        
        'Add the action sequence to the control
        ThisIbmTerminal.UiControlActionMapper.Add control, sequence
       
    End Sub
    See Also