Attaching macros to notebooks and buttons
Quattro Pro lets you attach macros to notebooks. A macro attached to a notebook can play when you open or close the notebook.
You can also attach a macro to a button. The button plays the macro. You can link a button you create to a macro script.
You can attach a macro to a keystroke. Macros attached to keystrokes are activated when you press the keystroke.
You can use the macro buttons you create to display the dialog boxes you create in Quattro Pro. For information about creating dialog boxes, see “Using custom dialog boxes and controls.”
Once you create a macro button, you can change the button properties by modifying the box type, border color, protection, and button name.
You can also attach a Quattro Pro or PerfectScript macro to a customized a command. For example, you can create a toolbar button and display it on any of the toolbars. When you click the button, the macro executes.
To attach a macro to a notebook |
1.
|
|
Right-click the top-left cell of the macro.
|
2.
|
|
Click Name cells.
|
3.
|
|
Type one of the following in the Name box:
|
•
|
_nbstartmacro — creates a startup macro that plays when you open the notebook
|
•
|
_nbexitmacro — runs a macro when you close the notebook
|
•
|
any block name (for example, “Fred” could be the name of a macro stored in a block)
|
4.
|
|
Click Add.
|
5.
|
|
Click Close.
|
•
|
|
You can also create a startup macro that plays when you open the notebook by typing (backslash zero).
|
To create a macro button |
1.
|
|
Click Insert Form control Push button.
|
2.
|
|
Click the spreadsheet.
|
3.
|
|
Drag the button to position it on the spreadsheet.
|
•
|
|
Clicking the spreadsheet creates a button at the default size. If you want to create a custom size button, drag to create the button.
|
•
|
|
You can also create a macro button by opening the Form Controls flyout on the Drawing tools toolbar and clicking the Push button tool.
|
To link a button to a macro |
1.
|
|
Right-click a button, and click Selection properties.
|
2.
|
|
Click the Macro tab.
|
3.
|
|
In the Enter macro box, type { (an opening brace), the macro command name, and } (a closing brace).
|
•
|
|
The maximum length for a macro command name is 200 characters.
|
To attach a macro to a keystroke |
1.
|
|
Select the starting cell of the macro.
|
2.
|
|
Click Insert Name Name cells.
|
3.
|
|
In the Name box, type ‘ (an apostrophe) and \ (a backslash), followed by a letter of the alphabet.
|
4.
|
|
Click Add.
|
To link a macro button to a dialog box |
1.
|
|
Right-click the macro button, and click Selection properties.
|
2.
|
|
Click the Macro tab.
|
3.
|
|
Click Execute dialog.
|
4.
|
|
In the Execute dialog dialog box, choose a dialog box from the Active dialog list.
|
5.
|
|
Type a cell reference in the Result cell box.
|
After the dialog box is closed, this cell contains 1 or 0. The value 1 means the dialog box was closed by clicking OK; the value 0 means it was closed by clicking Cancel.
|
6.
|
|
Type a cell reference in the Values range box:
|
Specify the cells that contain initial settings for the dialog box. When the dialog box is closed, its final settings are written into these cells.
|
•
|
|
You can also select a cell reference by clicking the Range picker tool.
|
To modify a macr
|
1.
|
|
Right-click a macro button, and click Selection properties.
|
2.
|
|
Click one of the following tabs:
|
•
|
Border color — changes the color around the outside of the button
|
•
|
Box type — changes the thickness of the line around the button or applies a shadow effect
|
•
|
Protection — locks the button, preventing users from moving or changing the button when protections are set at the spreadsheet level
|
•
|
Object name — changes the button’s name (used when referring to the button in a macro)
|
•
|
Print — enables the printing of chart objects on the spreadsheet.
|
•
|
Label text — changes the name displayed on the label
|
•
|
Macro — changes the button activation, URL link, or dialog box that displays when clicking the button
|
3.
|
|
Modify any settings.
|
To attach a macro to a toolbar button |
1.
|
|
Click Tools Customize.
|
2.
|
|
In the list of categories, double-click Workspace, Customization, and click Commands.
|
3.
|
|
Choose Macros from the list box.
|
4.
|
|
Choose a button graphic from the list.
|
5.
|
|
Click the Macro command category tab.
|
6.
|
|
Enable one of the following options:
|
•
|
Quattro Pro macro
|
•
|
PerfectScript macro
|
7.
|
|
Type the macro in the Enter macro box.
|
8.
|
|
Click the Appearance tab, and type a name in the Caption box.
|
9.
|
|
Click the General tab, and type text to use as the button’s Tool Tip in the Tooltip help box.
|
To add a macro button to the toolbar area |
1.
|
|
Click Tools Customize.
|
2.
|
| In the list of categories, double-click Workspace, Customization, and click Commands. |
3.
|
|
Choose Macros from the list box.
|
4.
|
|
Select a macro button you want to add to the toolbar area.
|
5.
|
|
Drag the macro button to the appropriate toolbar.
|