OpenOffice.org 2, Firefox, and Thunderbird for Windows All in One [Electronic resources]

Greg Perry, M. T. Cozzola, Jennifer Fulton

نسخه متنی -صفحه : 231/ 164
نمايش فراداده

129. Create and Use a Macro

128 About OpenOffice.org Macros

133 Associate OpenOffice.org and Microsoft Office Files

The process of recording a macro (a recorded sequence of commands) is mainly comprised of performing the commands as you normally would, only with the recorder turned on. The trick to making a proper recording, however, is setting up your document beforehand so that the commands you're recording can apply to

any document you may be editing in the future, not just the one you're looking at now.shortcut key . When that's finally done, you can type a single keystroke to have your OpenOffice.org application replay that macro very, very quickly.

KEY TERM

Shortcut key A keystroke, such as

Ctrl+Shift+B , that represents a command otherwise located within an onscreen menu or toolbar.

1.

Prepare Your Document

In either Writer of Calc, set up your document or spreadsheet to appear exactly as it should before you would normally execute the first action you intend to record as a macro. For example, if your macro is to change the formatting of a selected paragraph in Writer, select a paragraph now, and let that be the "guinea pig" selection for your macro recording.

2.

Start Recording

To begin recording, choose

Tools, Macros, Record Macro . The

Record Macro toolbar appears, containing a single button,

Stop Recording .

3.

Perform Actions to Be Recorded

Carefully reproduce all the actions you want the macro to repeat for you. The recorder takes note of every command you execute through the menu bar, a toolbar, or a keystroke shortcut. It will

not record actions made with the mouse directly to an open document, such as selecting a graphic on a page, clicking a different cell, or selecting a passage of text, so whenever possible, use the keyboard to perform such actions (for more, see

128 About OpenOffice.org Macros ).

129. Create and Use a Macro

128 About OpenOffice.org Macros .

6.

Test the Macro

This is a good time to make certain that the macro works the way you intend. Prepare a documenteither the open one or, in the case of macros saved to the

Standard library, a new documentwhose conditions approximate those from which you'll normally use your macro. Select

Tools, Macros, Run Macro . The

Macro Selector dialog box appears. From the

Library list, choose the location where your macro was stored. Unfortunately, this choice is not made automatically, so you must recall the location manually (by default,

My Macros, Standard, Module1 ). In the

Macro name list, choose the name of your recorded macro, and then click

Run .

The commands recorded in the macro are executed. You will not notice each step of the execution; you will only see the

results of the macro, instantaneously. This is because OpenOffice.org stops updating its own windows when executing a macro, which speeds things up tremendously.

Examine the results closely. If something appears amiss, repeat the test. If you don't get the results you intend after a second test, you can record the macro over again. Repeat this procedure from step 1, but in step 5, instead of entering a new name, choose the bad macro's name from the

Existing macros in list, and click

Save . A dialog box asks you to confirm overwriting the existing macro; click

Yes .

7.

Assign a Shortcut Key to the Macro

When the recorded macro works perfectly in simulated work conditions, you can assign it to a command or shortcut key so that you don't have to plow through libraries to get to it. Select

Tools, Macros, Organize Macros, OpenOffice.org Basic . The

OpenOffice.org Basic Macros dialog box appears. You do

not have to choose your macro's name at this point; instead, just click

Assign . The

Customize dialog box appears. Here, you can determine how the macro is to be triggered in the future.

For example, to assign the macro to a shortcut key, click the

Keyboard tab. To make this key execute the macro in all OpenOffice.org applications, click

OpenOffice.org in the upper-right corner; otherwise, click the name of the application from which you recorded the macro.

The

Shortcut keys list shows all possible keystrokes; those to which commands are presently assigned have the associated commands listed in the riost column. Unavailable keystrokes are shown in gray. Preferably, you should choose an unassigned keystroke from this list.

In the

Category list, choose

OpenOffice.org Macros, user , followed by the location of your recorded macro (for instance,

Standard, Module1 ). In the

Function list, choose the macro to which you want to assign the keystroke. Then click

Modify . The name of your macro should appear in the right column of the

Shortcut keys list, and the chosen keystroke should appear in the

Keys list. Click

OK to finalize this assignment, and then click

Close .