Adding Visual Basic for Applications macros

About this task

The basic interaction between Visual Basic for Applications andIBM® Rational® Rhapsody® is facilitated through the Rational Rhapsody COM API.

The Helpers window can also be used to add a Visual Basic for Applications macro. To add Visual Basic for Applications macros:

Procedure

  1. With a project open in Rational Rhapsody, choose Tools > Customize to open the Helpers window.
  2. Click the New icon New icon to add a blank line for a new Visual Basic for Applications macro menu command in the Menu content box.
  3. In the blank field, type the name of the new menu item (for example, My Visual Basic for Applications Command).
  4. Select the Visual Basic for Applications macro radio button as the helper type. The Helpers window lists Visual Basic for Applications‑specific options.
  5. Specify the applicable helper parameters:
    • In the Module box, enter the name of the Visual Basic for Applications module.
    • In the Macro name box, enter the name of the Visual Basic for Applications macro.
    • In the Applicable To list, specify which model elements to associate with the new command.

      If you do not specify a value for this field, the menu command for this link to a helper application might be added to the Tools menu depending on what you do in Step 6.
    • In the Project Type list, select a project profile.

      If leave this box blank, it uses as the default the profile of the current project you have opened.
    • In the Helper Trigger list, select the actions that triggers the new command.
  6. Depending on what you decided for the Applicable To list:
    • If you did not specify an applicable model element for the command, verify that the Show in Tools menu check box is selected. This means the new menu command for your link to a helper application displays on the Tools menu. If you clear this check box, there is no menu command for it on the Tools menu, though the link to the helper application still works once the command is started.
    • If you specified an applicable model element for the command, verify that the Show in Tools menu check box is selected. This means the new command displays in the menu for the specified model element. If you clear this check box, there is no menu command for it on the pop‑up menu for the specified model element, though the link to the helper application still works once the command is started.
  7. Click OK.
    The helper application you created is immediately available if the current project is within the parameters that you set for the helper application. For example, if the Rational Rhapsody project you currently have open uses the FunctionalC profile and you created the My New Command helper application for this profile, then this helper application is immediately available. However, if you specified the DoDAF profile (as selected in the Project Type list) for the My New Command helper application, then it does not work in your current project.

Results

Note: It is your responsibility to add code to your Visual Basic for Applications macro to verify that the selected object is actually the core object for your command. The COM command to get the selected element is getSelectedElement().

Feedback