Apache OpenOffice Calc · Formulas and analysis · Intermediate
Record and replay a document-owned macro in OpenOffice Calc
Record a harmless Paste Special macro inside an ODS document and replay it with explicit clipboard and selection prerequisites.
Documentation-qualified exercise; native application verification pending · Editorial standards
A recorded macro repeats the actions you record, not every action you performed before recording. This example stores a harmless multiplication operation inside the workbook and makes its clipboard and selection dependencies explicit.
Scope and security boundary
Use Apache OpenOffice Calc 4.1 desktop with English traditional menus and Windows/Linux keyboard conventions. The procedure follows the Calc macro-recorder chapter and the July 2026 OpenOffice 4.1 Getting Started guide. It is documentation-qualified, not native-tested.
Use only a disposable ODS workbook. Do not lower macro security, enable all macros, install an extension or run code from an unfamiliar document. If your existing policy blocks recording or execution, stop and retain the workbook for review through your normal process. This tutorial does not require changing that policy.
Enter A1:C3 as follows:
| A | B | C |
|---|---|---|
| 1 | 4 | 7 |
| 2 | 5 | 8 |
| 3 | 6 | 9 |
Save as macro-practice.ods and keep a separate untouched copy. The baseline sum of the nine cells is 45.
Record the operation, not its preparation
- Select A3, containing 3, and copy it to the clipboard.
- Select A1:C3. These two steps deliberately happen before recording.
- Choose Tools > Macros > Record Macro. A small dialog with Stop Recording appears.
- Choose Edit > Paste Special. Set the operation to Multiply and confirm with OK.
- Click Stop Recording. The OpenOffice Basic Macros dialog opens.
The expected values are now 3/12/21, 6/15/24 and 9/18/27 by row. Their sum is 135. This is the familiar Paste Special operation; the new outcome here is its recorded storage and replay lifecycle, not a second introduction to Paste Special.
Store the macro in this workbook
In the macro dialog select the current document, macro-practice.ods, rather than My Macros. Click New Module. If needed, Calc creates the Standard library; name the module Module1 or keep that default. Select the new module, enter PasteMultiply in Macro name, and click Save.
The intended location is the document’s Standard library, Module1, PasteMultiply. Document ownership matters: a macro stored in your personal library is not the same artifact as a macro traveling with this workbook. Save the ODS file after storing the module.
The official example records the Paste Special dispatch. It does not capture the earlier copy and range selection. Treat those as required inputs to every replay, not as incidental setup you can forget.
Reset and replay deliberately
Replace A1:C3 with the original nine numbers shown above. Copy A3 again while it contains 3, then select A1:C3. Choose Tools > Macros > Run Macro, locate this document’s Standard > Module1 > PasteMultiply, and click Run.
Confirm the same tripled values and sum 135. Do not run again without resetting: multiplying the tripled block by 3 would produce ninefold values with sum 405. Also do not copy A3 after tripling and assume it is still 3; it is now 9.
For a changed-input test, reset the original block, put 2 in E1, copy E1, select A1:C3 and run the same macro. Expected rows are 2/8/14, 4/10/16 and 6/12/18, sum 90. This proves the macro uses the current clipboard operand rather than a hard-coded multiplier of 3.
Inspect, save and recover
To inspect the recording, use Tools > Macros > Organize Macros > OpenOffice Basic, select the document macro and choose Edit. Review its purpose before reusing it; a recorder is not a safety guarantee for arbitrary actions.
Reset the fixture, save and close the ODS file, then reopen it under the existing macro policy. Verify the document-owned module is present. Re-establish the clipboard and selection before replaying; saved code does not preserve your transient clipboard state.
If results are wrong, stop and restore the untouched practice copy. Check operand, selection and whether the range was already multiplied before changing code. Keep real data out of the exercise.
Official references
OpenOffice 4.1 Calc: Using the Macro Recorder and OpenOffice 4.1 Getting Started with Macros, published 14 July 2026. Sources retrieved 20 October 2026; no macro execution is claimed.