Macros are an efficient way to make repetitive tasks and steps easier. This is especially true when you have multiple documents that could benefit from those same steps. Say you need to insert the same text over and over, or format numerous strings of text in a similar fashion. Those tasks can be made significantly easier with the help of macros. However, for many users, even the term "macro" equates to scripting or learning a programming language they have no need for otherwise.
Fear not, intrepid users, with LibreOffice there's no need to do a deep dive into scripting. With the help of a handy Macro recorder, you can easily save those keystrokes into the macro library for quick usage.
I'm going to show you how to do this. But do know, the LibreOffice macro feature has its limitations. Although it makes short shrift of recording keystrokes, it cannot handle the following:
- Opening of windows
- Carry out actions in another window (outside of where the recorder was started)
- Window switching
- Work with actions that are not related to the document content
- Actions made by the mouse (only keyboard actions can be made)
- Work outside of Calc or Writer
Limitations aside, macros are very helpful. Let's make this happen.
Recording a macro
I'm going to demonstrate recording a very simple macro—one that you can build on if needed. Let's say I'm working on a long document, and at the bottom of every page I need to include the following with specific formatting:
The content of this document reflects the writer's view and not the organization, CEO, or board of directors.
Type out the line of text, format it, and then copy it with [Ctrl]+[c]. Once you have the text in the clipboard, click Tools | Macros | Record Macro. When you do this, a tiny popup will appear, with a Stop Recording button. Paste the text into the LibreOffice Writer page (with [Ctrl]+[v]) and then click the Stop Recording button. A new window will appear (Figure A) where you name the macro and select the location to house it.
I highly recommend you save all of your custom macros to My Macros | Standard. Once you've named the located the macro, click Save. Your macro is now ready to use.
Using your macro
There are two ways to use your macro. The first is to click Tools | Macros | Run Macro. When the new window appears (Figure B), expand the entries in the left pane until you locate your newly created macro.
Select your macro, and then click Run. The necessary text will be added to wherever you've placed your cursor and you're good to go.
There's an easier way to run your macros by binding a keyboard shortcut. To do this follow these steps:
- Click on Tools | Customize | Keyboard
- In the resulting window (Figure C), select the Shortcut key to be used (making sure to select one that isn't currently in use)
- In the Category window, scroll all the way down until you see LibreOffice Macros
- Locate and select your macro
- Click OK
At this point, all you have to do is hit the assigned keyboard shortcut to run your newly created macro.
No coding necessary
How simple was that? Not one single line of coding had to be written to create your first macro. You can take this very simple example and expand upon it to create your own elegant macros that will save you more time than you realize.
- Video: Here's a look at LibreOffice's new interface options (TechRepublic Video)
- Cheat sheet: LibreOffice (TechRepublic)
- How to better collaborate on large documents using LibreOffice (TechRepublic)
- How to get rid of blank space at the bottom of LibreOffice Writer documents (TechRepublic Video)
- How to download LibreOffice documents from Google Drive in their native format (TechRepublic)
- LibreOffice 5.4: The best office suite gets better (ZDNet)
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.