LibreOffice more flexible than Microsoft Office for macros

A macro is an instruction into a set of instructions to perform a particular task. There are actually two ways to create macros in both office suites.

Macros allow you to perform and automate various functions in a document. Those functions can either be natively performed through a feature built into the application or they can introduce a new feature.

The simple way is to record a macro with an icon in the ribbon or by clicking the record item in one of the menus. The more complex way is to write code.

Many Microsoft Office power users are familiar with Visual Basic for Applications (VBA). This is the language Office records macros in. VBA is also the only language you can use to manually write macros with.

LibreOffice supports LibreOffice Basic, JavaScript, BeanShell and Python for creating macros. When you click the record button, LibreOffice writes the macro in LibreOffice Basic. To use the other languages, you need to write the code yourself.

This article compares recording macros in Microsoft Office applications and LibreOffice. For Microsoft, it will explain how macros are recorded for the Windows and Mac versions of Word, Excel, and PowerPoint.

Recording macros in Microsoft Office applications
For Windows
Word 2016
To record a macro in Word do the following:

Record Macro dialog in Word 2016 for Windows
After you click the Record Macro from the Macro icon, this dialog appears. It allows you to name the new macro and set it up.
  1. Open or create a document.
  2. Click the View ribbon.
  3. Click the arrow in the Macros section.
  4. Click record Macro.
  5. Type a name for the macro. The name cannot have spaces.
  6. Choose whether you want to make it available to other documents or just the one you are working on.
  • To make it available to all documents, choose All Documents in the Store macro in drop-down menu.
  • To only make the macro available to the document you are working on, choose the document in the Store macro in drop-down menu.
  1. You can either run a macro when you click a button or with a keyboard shortcut.
  • To run when you click a button:
  1. Click the Button icon. This opens a Word Options dialog.
  2. Click the new macro (it’s named something like Normal.NewMacros.<your macro name>)
  3. Click the Add button.
  4. Click the Modify button.
  5. Choose an icon from the Modify Button dialog.
  6. Choose an icon.
  7. Click the OK button in the dialog.
  8. Click the OK button in the Word Options dialog.
  9. Now record the macro. Note: Use the keyboard to select text while you’re recording your macro. Macros don’t record selections made with a mouse.
  10. To stop the macro, click the Macros arrow in the View ribbon. Then click Stop Recording in the menu.
  • To run with a keystroke:
  1. Click the Keyboard icon. This opens a Customize Keyboard dialog.
  2. The cursor will be flashing in the Press new shortcut key textbox. Type a key combination.
  3. Then click the Assign button.
  4. Now record the macro. Note: Use the keyboard to select text while you’re recording your macro. Macros don’t record selections made with a mouse.
  5. To stop the macro, click the Macros arrow in the View ribbon. Then click Stop Recording in the menu.

Excel 2016

  1. Open or create a document.

    Record Macro in Excel for Windows
    This is the dialog to set up and name a macro that you are about to record.
  2. Click the View ribbon.
  3. Click the arrow in the Macros section.
  4. Click record Macro.
  5. Type a name for the macro.
  6. Type a character in the box next to the Shortcut key.
  7. In the Store macro in drop-down menu there are several choices:
  • The this Workbook location will make it available to the spreadsheet you are working in.
  • Personal Macro Workbook, makes it available to all workbooks.
  1. Write a description, if you want one.
  2. Now record the macro. Note: Use the keyboard to select text while you’re recording your macro. Macros don’t record selections made with a mouse.
  3. To stop the macro, click the Macros arrow in the View ribbon. Then click Stop Recording in the menu.

PowePoint 2016
PowerPoint has a Macros item under the View ribbon. However, it doesn’t allow you to record macros like Word and Excel does. A Macro dialog opens when it is clicked.

The dialog allows you to name a dialog, then click the Create button. This opens the Visual Basic Editor, where you can write a macro.

You also can find previously created macros.

For Mac
Word 2016
Like the Windows version, Macros in the Mac version is available in the View ribbon. It also is located in the Macro sub-menu under the Tools menu.

Record Macro in Word for Mac
This dialog allows you to set up a macro that you are about to record. There are not as many features that are in the Windows version. This dialog also can be opened by clicking the Tools menu, highlighting the Macro sub-menu, then clicking Record Macro.
  1. Open or create a document.
  2. Click the View ribbon.
  3. Click the arrow in the Macros section.
  4. Click record Macro.
  5. Type a name for the macro. The name cannot have spaces.
  6. Choose whether you want to make it available to other documents or just the one you are working on.
  • To make it available to all documents, choose All Documents in the Store macro in drop-down menu.
  • To only make the macro available to the document you are working on, choose the document in the Store macro in drop-down menu.
  1. You can either run a macro when you click a button or with a keyboard shortcut.
  • To record it as a listed item:
  1. Simply click the OK button.
  • To run with a keystroke:
  1. Click the Keyboard icon. This opens a Customize Keyboard dialog.
  2. The cursor will be flashing in the Press new shortcut key textbox. Type a key combination.
  3. Then click the Assign button.
  4. Now record the macro. Note: Use the keyboard to select text while you’re recording your macro. Macros don’t record selections made with a mouse.
  5. To stop the macro, click the Macros arrow in the View ribbon. Then click Stop Recording in the menu.

Excel 2016
The Mac version of Excel is similar to the Windows version. The Record Macro button, however, is a separate icon in the View ribbon. It also is located in the Macro sub-menu under the Tools menu.

Record Macro in Excel for Mac
This dialog allows you to set up a macro that you are about to record. There are not as many features that are in the Windows version.
  1. Open or create a document.
  2. Click the View ribbon.
  3. Click the arrow in the Macros section.
  4. Click record Macro.
  5. Type a name for the macro.
  6. Type a character in the box next to the Shortcut key.
  7. In the Store macro in drop-down menu there are several choices:
  • The this Workbook location will make it available to the spreadsheet you are working in.
  • Personal Macro Workbook, makes it available to all workbooks.
  1. Write a description, if you want one.
  2. Now record the macro. Note: Use the keyboard to select text while you’re recording your macro. Macros don’t record selections made with a mouse.
  3. To stop the macro, click the Macros arrow in the View ribbon. Then click Stop Recording in the menu.

PowerPoint 2016
PowerPoint for Mac does not allow you to record a macro. Like the other applications, there is a Macro icon in the View ribbon. It is also located in the Macro sub-menu of the Tools menu.

Click the icon and a Macros dialog opens, allowing you to run previously created macros.

The Macro sub-menu has a Visual Basic Editor item. Clicking this opens the Visual Basic Editor dialog for Microsoft Office.

LibreOffice
Recording macros in the different LibreOffice applications is done the same way. The Recording Macro item is in the Macro sub-menu in the Tools menu of all the applications.

Recording macros in a LibreOffice application is an advanced feature that most likely needs to be activated before it appears in the Tools menu.

Options dialog in LibreOffice Advanced tab
The Advanced tab in the Options dialog of LibreOffice lets you set the office suite so you can record macros.

To activate it do the following:

  1. If you are using LibreOffice on a Mac, click the LibreOffice menu.
  • In other operating systems, click the Tools menu.
  1. On a Mac, click the Preferences item.
  • In other operating systems, click the Options item.
  1. In the left column, reveal the items under LibreOffice.
  2. Click the Advanced item.
  3. In the main section, put a check in the box for Enable macro recording.

The next step is to open or create a document in one of the applications.

Record Macros in LibreOffice
This image shows where the Record Macros item is in the Tools menu. Click it, perform the desired task, then click the stop recording item in the small dialog.
  1. Click the Tools menu.
  2. Highlight the Macros sub-menu.
  3. Click Record Macros.
  4. Perform the task that you want to be automated.
  5. After you are done, click Stop Recording in the dialog that has appeared. This opens the LibreOffice Basic Macros.
  6. By default the macro will be called Main, and placed under Standard under My Macros. Type a new name in the Macro Name text field.
  7. Click the Save button.
  8. Now the macro can be reused in other documents and applications.

Like the Mac and Windows of PowerPoint, LibreOffice Impress does not allow you to record a macro in a presentation. The Record Macro will be inactive.

Conclusion
For creating simple macros, both LibreOffice and Microsoft Office are about equal. LibreOffice has one way of doing it, so it is easier to use than Microsoft Excel and Word 2016. The Microsoft applications, however, has more options that can be accessed through its dialog. For example, there are options to easily set up a macro as a button or as a keystroke.

The macros are written in different languages, so you could not create a macro in LibreOffice and run it using Microsoft Office. However, macros created in a document created in Microsoft Office can be run in LibreOffice. Make sure the security settings in the Options dialog is set to allow macros from unknown sources.

In addition to being able to run the simple macros recorded in Microsoft Office, programmers also can use JavaScript, Python, and BeanShell to create more complex macros. This makes LibreOffice more flexible than Microsoft Office, since Office only uses one language for macros.

LibreOffice maybe the better choice for running macros for this reason. While most professionals probably won’t switch from Office, they may use LibreOffice to augment their work.

Leave a Reply

Your email address will not be published. Required fields are marked *