Run a macro - how to from a sheet Button, toolbar?

In Macros Explained book says that you can run a macro

  1. by placing it first in the module - but in a .ods file, Standard is my first library and clicking ‘Run’ just opens up an involved Dialog where I need to navigate to my .odt and pickout the module.
  2. use first macro to run everything else - but (1) is already a problem so…
  3. use ‘Macro dialog’ - well that involves browsing
  4. add a button to doc (or toolbar) - how??
  5. I got the last suggestion working - keyboard shortcut

Is there a quick way to run my test macro vs all this messing about with menus and setup?

Hello,

Please see → Adding a Command Button to a Document

Another is → How to Add Push Button on Calc Sheet and Use It

You can also add or modify a toolbar. See LO documentation → Getting Started with LibreOffice. See Chapter 14.

I tried https://i.imgur.com/p4Wcciy.png but the Button does not do anything when clicked… (after ‘Properties’ is closed) It’s supposed to display a ‘Hello World’ dialog/by running the Macro. This works via Toolbar https://i.imgur.com/iRs7lUp.png

@vek.m1234,

Can’t see exactly where your macro is located. It should be in the Standard library of My Macros and Dialogs or of the document.

oh nm, we need to switch the button Mode to ‘Design Mode’ off

How to assign a macro to an user interface item:

Tools - Customize - select a TAB:

  • Menu
  • Toolbars
  • Context menus
  • Keyboard
  • Events

For the Menu, Toolbars, Context menus:

Select the Target and the Scope, and the position from the Function list under the Target. The assigned macro will be located under the selected item.

Then select the Macros from the Category list.

Browse your macro routine from the Macro Function list.

Use the right arrow to assign the macro routine to the position. (the left arrow removes a selected item)

You can modify the Icon of the Toolbar-item, and you can modify the label text of the Menu item and the Context menu item.