Help with macro in LOWriter

In a previous version of LibreOffice I had created a macro that I called upon with a keyboard shortcut. It worked like this:
I would highlight text in libreoffice writer and hit the assigned key (F4) and the selected text would be marked as norwegian language.

This was very usefull because I get a lot of small texts in other languages that I translate to norwegian.

Then I changed OS to Manjaro KDE and upgraded LO to 6.3.6.2 and happily re-created the macro from scratch. The macro worked that first time. Now, whenever I call upon the macro in a new document I get:

A Scripting Framework error occurred while running the Basic script vnd.sun.star.script:Standard.Module1.norsk?language=Basic&location=application.

Message: The following Basic script could not be found:
library: ‘Standard’
module: ‘Module1’
method: ‘norsk’
location: ‘application’

And if I open the macro (as if I wanted to edit it, not that I would know how to do that) I get another error saying:

BASIC syntax error.
Sub procedure or function procedure set_nor already defined.

I am a pretty basic user of LibreOffice so I have no idea what this means, and I was hoping somebody would be able to lend me a hand.

Thank you!

Thank you Lupp for your comments!

  1. Yes, Tools->language for selection, is the best option because the document may contain texts in other languages too.
  2. Not sure if I understand what you mean, but I want the language set to Norwegian so that I can use spellcheck and make sure I don’t leave any typo in the text.
  3. I went Tools-> Organize macros → LibreOffice Basic Macros and there I looked up my macro under My Macros > Standard > Module1. Then I selected it and hit Edit.

But… It seems I found the solution. I created the macro again and this time when trying to assign it to a keyboard shortcut I got an error saying I needed to install JRE. I did that and it seems to work now. I have tried opening several different documents and so far it looks good.

Just a few questions in return:
-1- Do you actually want to set the language like via >Tools>Language>For Selection?
-2- In what way do you want to make use of the setting?
-3- Where ( in what way exactly) did you open the macro for editing? At what step came the error message?
Please don’t use the ‘Add Answer’ feature for the purpose, but append information to your question by edditing, or add another comment below.

Quoting @eexxil;
3. I went Tools-> Organize macros → LibreOffice Basic Macros and there I looked up my macro under My Macros > Standard > Module1. Then I selected it and hit Edit.
I still can’t understand how you might get the second error message this way. - and the first message tells the assigned macro should have the simple name “norsk”, not something like “set_nor”.
(I will have a break now.)

There may be a problem with your user profile.
I can, however, not tell you anything specific concerning your OS. If the example and the described proceeding don’t work for you, another user of KDE may help. My own experiences with KDE are too old (>6 a) and mostly forgotten.

I made an example for you containing additional explanations.
Please open it, move the (prettier) macro to the mentioned local library of your system, customize F4 (or the key you now prefer) newly to it, and try it out.
Please report the success.
Example:
ask254736setLanguagePerTextRangeByMacro_1.odt

It seems I found the solution. I created the macro again and this time when trying to assign it to a keyboard shortcut I got an error saying I needed to install JRE. I did that and it seems to work now. I have tried opening several different documents and so far it looks good.

Should I close this question now?

You shouldn’t need a JRE with a recent LibreOffice for this. There are still a few messages, however, claiming it. This should be a bug.