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:
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.
Open or create a document.
Click the View ribbon.
Click the arrow in the Macros section.
Click record Macro.
Type a name for the macro. The name cannot have spaces.
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.
You can either run a macro when you click a button or with a keyboard shortcut.
To run when you click a button:
Click the Button icon. This opens a Word Options dialog.
Click the new macro (it’s named something like Normal.NewMacros.<your macro name>)
Click the Add button.
Click the Modify button.
Choose an icon from the Modify Button dialog.
Choose an icon.
Click the OK button in the dialog.
Click the OK button in the Word Options dialog.
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.
To stop the macro, click the Macros arrow in the View ribbon. Then click Stop Recording in the menu.
To run with a keystroke:
Click the Keyboard icon. This opens a Customize Keyboard dialog.
The cursor will be flashing in the Press new shortcut key textbox. Type a key combination.
Then click the Assign button.
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.
To stop the macro, click the Macros arrow in the View ribbon. Then click Stop Recording in the menu.
Excel 2016
Open or create a document.
This is the dialog to set up and name a macro that you are about to record.
Click the View ribbon.
Click the arrow in the Macros section.
Click record Macro.
Type a name for the macro.
Type a character in the box next to the Shortcut key.
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.
Write a description, if you want one.
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.
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.
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.
Open or create a document.
Click the View ribbon.
Click the arrow in the Macros section.
Click record Macro.
Type a name for the macro. The name cannot have spaces.
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.
You can either run a macro when you click a button or with a keyboard shortcut.
To record it as a listed item:
Simply click the OK button.
To run with a keystroke:
Click the Keyboard icon. This opens a Customize Keyboard dialog.
The cursor will be flashing in the Press new shortcut key textbox. Type a key combination.
Then click the Assign button.
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.
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.
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.
Open or create a document.
Click the View ribbon.
Click the arrow in the Macros section.
Click record Macro.
Type a name for the macro.
Type a character in the box next to the Shortcut key.
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.
Write a description, if you want one.
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.
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.
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:
If you are using LibreOffice on a Mac, click the LibreOffice menu.
In other operating systems, click the Tools menu.
On a Mac, click the Preferences item.
In other operating systems, click the Options item.
In the left column, reveal the items under LibreOffice.
Click the Advanced item.
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.
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.
Click the Tools menu.
Highlight the Macros sub-menu.
Click Record Macros.
Perform the task that you want to be automated.
After you are done, click Stop Recording in the dialog that has appeared. This opens the LibreOffice Basic Macros.
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.
Click the Save button.
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.
Comments