Bug 94522 - Keyboard shortcut assigned to a macro is not saved in the document
Summary: Keyboard shortcut assigned to a macro is not saved in the document
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
4.4.3.2 release
Hardware: Other All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: needsUXEval
Depends on:
Blocks: Shortcuts-Accelerators
  Show dependency treegraph
 
Reported: 2015-09-26 08:25 UTC by gmolleda
Modified: 2026-01-30 18:23 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot of the proposed UI (115.96 KB, image/png)
2026-01-21 19:26 UTC, Neil Roberts
Details
Proposed UI with a third radio button (128.25 KB, image/png)
2026-01-30 10:25 UTC, Neil Roberts
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gmolleda 2015-09-26 08:25:33 UTC
Atajo de teclado asignado a una macro no se guarda en el documento:

Falta que LibreOffice guarde la tecla asignada a una macro en el fichero del documento cuando la macro está guardada en tal fichero. Así si creas una macro y le asignas una tecla, al abrir el fichero en otro ordenador, siga funcionando la macro con la misma tecla y no haya que volver a configurar la tecla en cada ordenador donde se vaya a abrir el documento.

Por supuesto que esa asignación debería ser olvidada en cuanto se cerrara el documento o se pasara a otro, pues no afectaría al programa en general, sólo a ese documento que contiene la macro.
______________________________________________________
Klavkombino atribuita al makroo ne konservas en dokumenton:

LibreOffice devas konservi la klavkombinon en la dosiero kiam la makroo estas savita en tiu sama dosiero. Do se vi kreas makroon kaj atribuas klavkombinon, kiam ĝi malfermas la dosieron en alia komputilo, la makroo daŭre funkciigas kun la sama klavkombino kaj ne devas reagordi la klavkombinon en ĉiu komputilo kie malfermos la dokumenton.

Kompreneble, tiu atribuo devus esti forgesita tuj kiam la dokumento estas fermita aŭ interŝanĝis al alia, kiel ĝi ne tuŝus la ĝeneralan programon, nur ke la dokumento enhavanta la makroon.
______________________________________________________
Using English internationally is discriminatory for nationality (racism) and salary (classicism). Esperanto is better as a world's second language.

Keyboard shortcut assigned to a macro is not saved in the document:

LibreOffice need to keep assigned to a macro file in the document when the macro is saved in this key file. So if you create a macro and assign a key to open the file on another computer, the macro continues to operate with the same key and not have to reconfigure the key on each computer where it is to open the document.

Of course, that allocation should be forgotten as soon as the document is closed or switched to a different, as would not affect the overall program, only that the document containing the macro.
Comment 1 gmolleda 2015-09-27 14:49:37 UTC
-------- Español ---------
Mientras se puede crear el atajo de teclado desde la propia macro y luego eliminar el atajo al cerrar el documento tal como enseñan a hacer en este blog:
http://blog.open-office.es/index.php/basic/2015/09/26/macro-para-asignar-una-macro-a-un-atajo-de-teclado

-------- Esperanto ---------
Intertempe vi povas krei la klavkombinon en la makroo kaj poste ĝi forigos la klavkombinon kiam vi fermos la dokumenton kiel ilia instruas en la blogo (en la hispana):
http://blog.open-office.es/index.php/basic/2015/09/26/macro-para-asignar-una-macro-a-un-atajo-de-teclado

-------- English ---------
While you can create a keyboard shortcut for the macro itself and then delete the shortcut to close the document as taught to do in this blog (in Spanish):
http://blog.open-office.es/index.php/basic/2015/09/26/macro-para-asignar-una-macro-a-un-atajo-de-teclado
Comment 2 tommy27 2016-11-26 05:58:54 UTC
enhancement request. status NEW.
needsDevEval to see if this is technically feasible.
Comment 3 Cor Nouws 2017-03-06 14:32:41 UTC
(In reply to gmolleda from comment #0)
> Keyboard shortcut assigned to a macro is not saved in the document:

Hi gmolleda: do you know if this worked in older versions?
I see bug 103586 and that used to work in the past..
Thanks - Cor
Comment 4 gmolleda 2019-04-14 06:44:33 UTC
English in the end of comment:

Esperanto:
Mi ne pensas tion. Kion mi demandas estas, ke se la fulmolavo estas aplikita al makroo ene de Calc-libro, la fulmoklavaroj devas esti konservitaj ene de la dosiero por ĝi estu importita al alia komputilo kiam la dosiero malfermiĝas.
Estus necese apartigi, kiel la makroojn, inter LibreOffice fulmoklavaroj kiel programo, de la fulmoklavaroj de specifa libro aŭ dosiero.

Español:
Yo no creo, lo que pido es que si el atajo de teclado se aplica a una macro dentro de un libro de calc, el atajo de teclado debe guardarse dentro del fichero para poder ser importado en otro ordenador cuando abra el fichero.
Haría falta separar, igual que las macros, entre atajos de teclado de libreoffice como programa, de los atajos de teclado de un libro o fichero concreto.

English:
I do not think. That I'm asking is that if the keyboard shortcut is applied to a macro within a calc book, the keyboard shortcut must be saved inside the file so it can be imported into another computer when the file is opened.
It would be necessary to separate, like the macros, between libreoffice keyboard shortcuts, from the keyboard shortcuts of a particular book or file.
Comment 5 chbok 2020-06-26 19:50:27 UTC
I fully understand the bug. I also tried to associate a keyboard shortcut with a macro inside a document, so that other users could access it easily.

Unfortunately, this is not possible. The customize menu does not allow you to assign a shortcut only to libreoffice, but not to a document (calc or doc). The shortcut therefore only works on the computer that assigned it.
Comment 6 Neil Roberts 2026-01-19 15:37:56 UTC
For what it’s worth, it looks like all the plumbing necessary to implement this is already in the source code, it’s just missing a UI to set the keyboard shortcuts. You can however set a document shortcut to a macro with LibreOffice BASIC. For example, if you have a macro called “Main” defined in your document, you can run this bit of BASIC to assign the macro to F7. This assignment will be stored in the .odt file and then when you open the document with a different instance of LibreOffice, you can just press F7 to run the macro (assuming you have macros enabled in the security options). You can delete the code once it has been run once to assign the shortcut.

Sub SetShortcutKey
	uiconf = ThisComponent.getUIConfigurationManager()
	shortCutManager = uiconf.getShortCutManager()
	Dim key as new com.sun.star.awt.KeyEvent
	key.KeyCode = com.sun.star.awt.Key.F7
	shortCutManager.setKeyEvent(key, "vnd.sun.star.script:Standard.Module1.Main?language=Basic&location=document")
	shortCutManager.store()
End Sub

(ps, saluton samideano :) )
Comment 7 Neil Roberts 2026-01-21 19:26:50 UTC
Created attachment 205119 [details]
Screenshot of the proposed UI
Comment 8 Neil Roberts 2026-01-21 19:29:50 UTC
I had a go at implementing a UI for this here:

https://gerrit.libreoffice.org/c/core/+/197709

That makes it work the same way as the toolbar and menu tabs, ie, there is a dropdown list box to select the scope of the accelerator which can be the entire office suite, the module of the current document or just a particular document. I’ve attached a screenshot.

I don’t know if the bug now needs UX feedback. I’m setting needsUXEval in case.
Comment 9 Heiko Tietze 2026-01-28 12:04:39 UTC
(In reply to Neil Roberts from comment #8)
> I’m setting needsUXEval in case.

To alert people you should add ux-advice@ to CC.

I commented on Gerrit that radio buttons would be more clear, the choice itself is bad (bug 66298), and a redesign desirable (bug 115527 and bug 115052).

More general, shortcuts defined in documents allow to easily switch from one assignment to another per template. And sharing those templates is simple too.
Comment 10 Neil Roberts 2026-01-30 10:25:51 UTC
Created attachment 205270 [details]
Proposed UI with a third radio button

Heiko suggested on Gerrit that we could add a third radio button to select the document. I had a go at implementing that in case we decide to merge that patch as an interim interface until the redesign is implemented. It is PS7 on the gerrit page. I’m attaching a screenshot.
Comment 11 Heiko Tietze 2026-01-30 13:41:45 UTC
(In reply to Neil Roberts from comment #10)
> I’m attaching a screenshot.
The dropdown should be disabled unless the "(o) Document" radio button is selected. Seems you can select a document even if the module is active. Besides: LGTM.
Comment 12 Neil Roberts 2026-01-30 18:23:14 UTC
> The dropdown should be disabled unless the "(o) Document" radio button is selected.

Ok, I’ve made this change in PS8. Thanks.

Originally it worked so that if you selected a document in the dropdown then it would automatically select the document radio button, which would save a click. But now I see that other dialog boxes don’t work like that and it’s a bit confusing, so I agree that it’s better to just disable the dropdown.