Automate Tasks with LibreOffice Macro Recorder
The LibreOffice macro recorder allows users to automate repetitive actions—such as formatting tables, inserting boilerplate text, and cleaning data—by recording user interactions and replaying them on demand. This guide explains how to enable the built-in macro recorder, record a sequence of steps, save the macro to your library, and assign it to a keyboard shortcut or toolbar button for quick execution.
1. Enable Macro Recording
By default, the macro recording feature is turned off in LibreOffice. To activate it:
- Open any LibreOffice application (Writer, Calc, Impress, etc.).
- Go to the menu bar and select Tools > Options (or LibreOffice > Preferences on macOS).
- In the left pane, expand LibreOffice and click Advanced.
- Under the Optional Features section, check the box for Enable macro recording (may be limited).
- Click Apply, then OK.
2. Record a New Macro
Once enabled, you can record actions directly within your document:
- Navigate to Tools > Macros > Record Macro. A small floating dialog box with a Stop Recording button will appear.
- Perform the repetitive sequence of actions you want to automate (such as changing font styles, inserting pre-set tables, or applying specific cell formulas in Calc).
- Once the sequence is complete, click the Stop Recording button on the floating dialog.
3. Save the Macro
After stopping the recording, the LibreOffice Basic Macros dialog will appear:
- Select a storage location:
- My Macros > Standard > Module1: Saves the macro globally across all LibreOffice documents on your computer.
- [Current Document Name] > Standard: Saves the macro only inside the active file.
- In the Macro Name field, enter a descriptive,
alphanumeric name without spaces (e.g.,
FormatHeaderTable). - Click Save.
4. Run the Macro
To execute your saved macro:
- Go to Tools > Macros > Run Macro.
- Expand the library where you saved your macro (e.g., My Macros > Standard > Module1).
- Select the macro name from the list on the right.
- Click Run.
5. Assign a Keyboard Shortcut or Toolbar Icon
To speed up execution, you can bind your macro to a key combination or toolbar button:
- Go to Tools > Customize.
- Select the Keyboard tab (or Toolbars tab to add an icon).
- In the Category list at the bottom left, scroll down and expand LibreOffice Macros > user > Standard > Module1.
- Select your macro in the Function list.
- Choose an available shortcut key from the Shortcut Keys list above.
- Click the Assign button in the top right corner.
- Click OK to save the changes.
Macro Recording Best Practices
- Use keyboard shortcuts during recording: The macro recorder tracks keyboard inputs and menu commands more reliably than mouse clicks inside the document window.
- Keep macros focused: Record small, task-specific macros rather than long, complex sequences to minimize errors during replay.
- Inspect the code: To view or edit the underlying code, go to Tools > Macros > Edit Macros to modify the generated LibreOffice Basic script.