Running macros

Macros are used to update the data in the Microsoft Word and Microsoft Excel output that is generated from IBM Engineering Lifecycle Optimization - Publishing (PUB). You can choose to run the macro directly from PUB by using the macro name property or you can add it as a post-processing command to run it on the generated output.

Before you begin

The product comes with sample style sheets that contain macros and VBScript files. In the ...\utils\word\ directory, you can find three files and in the ...\utils\excel\ directory, you can find two files:

Table 1. Files that come with the product that contain macros for Microsoft Word
File path and name Description
PUB_install_dir\utils\word\rpe.dot

A style sheet that contains macros.

PUB_install_dir\utils\word\rpe_signed.dot

A style sheet that contains macros.

PUB_install_dir\utils\word\runmacro.vbs

A scripting file that can run macros.

Both rpe.dot and rpe_signed.dot contain the same styles and macros, but the rpe_signed.dot version contains an electronic signature for source verification. These files contain macros that can embed OLEs and update the output fields for Table of contents, Table of figure, and Table of table elements. The runmacro.vbs macro accepts 0 - 10 arguments for the Microsoft Word macro. You can use these macros or record your own.
Table 2. Files that come with the product that contain macros for Microsoft Excel
File path and name Description
PUB_install_dir\utils\excel\rpe.xltm

A style sheet that contains macros.

PUB_install_dir\utils\excel\runmacro.vbs

A scripting file that can run macros.

The style sheet rpe.xltm contains sample macros that can be used to add any chart, position the chart, delete the sheets based on certain conditions, and more.

About this task

When you use the macro name property, the macro is run from PUB and the data is updated before the output is generated. When you use the post-command property, the macro is run by Microsoft Word and Microsoft Excel to update the data after the output is generated.
Note: If you are using variables in your macro argument, you must use the post-command property to run your macro.

Running the macro by using the Macro name property

Procedure

  1. Record or specify the macro in the Microsoft Word or Microsoft Excel document that is being used as a style sheet.
  2. In the Launcher application, select the template that is listed in the document specification view.
  3. If you are using a style sheet that contains macros, for the style sheet property, enter the path to the document-style report or style sheet that contains the macro.
  4. For the Macro name property, enter an argument. Variables cannot be used in your argument.
    Example: macro_name macro_argument
  5. Generate the output.

Results

The macro is run from PUB and the data is updated before the output is generated.

Running the macro by using the post-command property

About this task

System variable names, output names, and template variables can be used in your command.

Procedure

  1. Record or specify the macro in the Microsoft Word or Microsoft Excel document that is being used as a style sheet.
  2. In the Launcher application, select the template that is listed in the document specification view.
  3. If you are using a style sheet that contains macros, for the style sheet property, enter the path to the document-style report or style sheet that contains the macro.
  4. For the post-command property, enter an argument using the cscript command. The cscript command is used to start the Windows Script interpreter to run the macro.
    Example:
    • cmd /c cscript "PUB_install_dir\utils\word\runmacro.vbs" "${Word}" macro_name "${varA}"
    • cmd /c cscript "PUB_install_dir\utils\excel\runmacro.vbs" "${Excel}" macro_name "${varA}"
    Note: If your argument contains white spaces, you must enclose the argument in quotation marks (" ").
  5. Generate the output.
    varA is replaced with the value of the variable that is specified in the template.

Results

The macro is run by Microsoft Word or Microsoft Excel to update the data after the output is generated. varA is replaced with the value of the variable that is specified in the template.