Macro to change paragraph style

Hey There!

Please note, that this is the first time I use macros in libreoffice.

I want to write a screenplay, and for this I often have to jump between different paragraph styles. So I decided to make a macro, witch can be startet with a shortcut, which lets you quickly choose a paragraph style.

So for example, when I press command + T there should popup a little window like this:
Bildschirmfoto 2021-12-21 um 01.30.10

Then I want to press one of the keys in brackets on my keyboard, for example S, and the paragraph style should then change to “Scene Heading” and the little popup should go away until I press the shortcut comand + T again.

I know how to combine a macro with a shortcut, which then shows the pop up. But could you give me a tip on how I can program the whole thing in basic?

Unless you insist to use a macro for curiosity’s sake or personal knowledge improvement, you have two built-in ways of doing this:

  • keyboard shortcuts
    With Tools>Customize, you can assign free key combinations to a style (and style may be any category, e.g. character, which extends your specification)

  • selection by name

    • press F11 (the cursor disappears to tell you are in a “meta” mode); style side pane shows up if it was not visible
    • type the beginning of the style name; selection moves in the list
    • hit Enter as soon as the desired style is selected; cursor is reenabled in text window

    Drawback: you can select only in the displayed category. If you want to select within another style category, you must first click on the icon in the style toolbar.

Thanks for your respond.
I solved it with shortcuts to the different Styles and i’m satisfied with it :slight_smile:

Another help is if you select Applied styles at the bottom of the styles pane, you will see only styles that are in your document.