About this task
You can create a new macro or edit an existing
macro in two ways:
- Using the Visual Basic for Applications Macros
window inIBM® Rational® Rhapsody®
- To create a macro, type in a new name in the Macro
Name field, then select Create.
Note: Since Visual Basic for Applications macros are contained
in modules, you must first create a module before creating your first
macro. If you have not yet created a module, the Create button
is disabled. Modules cannot be created from the Macros window. You
must open the Visual Basic for Applications IDE to do so.
- To edit a macro, highlight the existing macro in
the Macro window, then select Edit.
- Launch the Visual Basic for Applications IDE and
create and edit new macros there. There, you can do one of the following
actions:
- Select to open the Macros window.
Start typing the new macro with the line Sub xxxx(),
where xxxx is the name of the new macro. The last line of the
macro must be "End Sub."
- Find an existing macro by expanding the Modules
folder of the Project window and double-clicking the appropriate module.
You can scroll the code window to the existing macro or select it
in the right pull-down above the code window.
Example of a Visual Basic for Applications
macro:
Sub GetNameOfProject()
Dim a as Object
Set a = getProject
MsgBox a.name
End Sub
Once you have finished typing this
macro, return to the Rational Rhapsody window
and run the new macro through the Macros window. You see a small message
box with the name of the currently loaded project.