My macros disappeared from LibreOffice Basic Macros

Hello,

Over the years, I have set up about 15 macros for various purposes, some recorded, some hand-written. A couple of days ago, they mysteriously disappeared. That is, they are not there anymore under Macros → Organize Macros → LibreOffice Basic… They used to be there under Standard → Module1 (if I remember correctly). But now there is no Standard → Module1 anymore under LibreOffice Basic Macros. What might have happened? Where did the macros go? How can I reestablish them?

The only possible cause of the disappearance of the macros that I can think of is that LibreOffice crashed twice during the last days while editing a particular document.

Thanks a lot in advance for your help!

Macros are stored either in the document or in the user profile.
.
If you are in safe mode your profile is not used. Your macros would not be seen.
.
Maybe your profile was re-created, the let’s hope the old one is not deleted…

Location depends on your (not mentioned) OS, see link below. For Windows start in %APPDATA% wich is the place choosen by Microsoft (wich should be included in every backup).

https://wiki.documentfoundation.org/UserProfile

1 Like

Thank you, Wanderer, for the prompt reply! I am on Linux. Sorry for forgetting to mention that! Following your suggestion, I could find the macros under /home/Wolfhart/.config/libreoffice/4/user/basic/Standard/Module1.xba. But the macros do not show up under Macros → Organize Macros → LibreOffice Basic… Does that mean that LibreOffice is running in safe mode? If so, how do I make it stop running in safe mode?

Don’t know why LO does not see them. First step would be to create a backup copy, then check the contents of the xba-File, if your macros are inside (module could be empty…).

The macros are in the xba file, I checked.

Could LO be running in safe mode? How do I know whether it is running in safe mode?

Maybe the following helps: I usually activate the macros with a keyboard shortcut. When I do so now, I get the following error message:

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

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

I saw a number of “macros disappeared” questions over ~recent time; it would be awesome if affected users could find which piece in their user profile (registrymodifications) were responsible, by backing up the problematic profile, resetting their profile, and trying to bring back parts of problematic profile, until the problem re-appears.

Open /home/Wolfhart/.config/libreoffice/4/user/basic/script.xlc with a text editor. This file contains a registry of all script libraries.
If “Standard” is your only library, it should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:libraries PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "libraries.dtd">
<library:libraries xmlns:library="http://openoffice.org/2000/library" xmlns:xlink="http://www.w3.org/1999/xlink">
 <library:library library:name="Standard" xlink:href="$(USER)/basic/Standard/script.xlb/" xlink:type="simple" library:link="false"/>
</library:libraries>

dialog.xlc is the registry of all dialog libraries. It looks like this, even if you don’t have any dialogs:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:libraries PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "libraries.dtd">
<library:libraries xmlns:library="http://openoffice.org/2000/library" xmlns:xlink="http://www.w3.org/1999/xlink">
 <library:library library:name="Standard" xlink:href="$(USER)/basic/Standard/dialog.xlb/" xlink:type="simple" library:link="false"/>
</library:libraries>

WIthin the Standard subdirectory, you find script.xlb and dialog.xlb where the modules of the Standard library are defined.

script.xlb with an entry for Module1:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="Standard" library:readonly="false" library:passwordprotected="false">
 <library:element library:name="Module1"/>
</library:library>

dialog.xlb with no dialog:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="Standard" library:readonly="false" library:passwordprotected="false">
</library:library>

In order to avoid the problem of disappearing macros, store them in your own library instead of “Standard” and adjust your keyboard shortcuts, buttons etc. accordingly.

3 Likes

Please note that, even though the script files are present, the two summary files script.xlc and dialog.xlc should be in the user/basic subdirectory.

Of course, those two files should hold references to your macros. This means that if they are empty, your macros are not seen by LO.

Here’s a sample on my system:

<?xml version="1.0" encoding="UTF-8"?>

<library:libraries xmlns:library=“http://openoffice.org/2000/library” xmlns:xlink=“http://www.w3.org/1999/xlink”>
<library:library library:name=“Standard” xlink:href="$(USER)/basic/Standard/script.xlb/" xlink:type=“simple” library:link=“false”/>
<library:library library:name=“XrayTool” xlink:href="$(USER)/basic/XrayTool/script.xlb/" xlink:type=“simple” library:link=“false”/>
<library:library library:name=“MasterSlideDuplication” xlink:href="$(USER)/basic/MasterSlideDuplication/script.xlb/" xlink:type=“simple” library:link=“false”/>
<library:library library:name=“FusionBudgets” xlink:href="$(USER)/basic/FusionBudgets/script.xlb/" xlink:type=“simple” library:link=“false”/>
</library:libraries>

Where XrayTool, MasterSlideDuplication and FusionBudgets are the three macro libraries present in MyMacros.

HTH,

1 Like

Thank you very much, Villeroy! Changing the contents of the four files you indicate (script.xlc, dialog.xlc, script.xlb, dialog.xlb) solved the problem.

What I found was that script.xlc and dialog.xlc (in user/basic) were empty, and script.xlb (in user/basic/Standard) was missing <library:element library:name=“Module1”/>.

Do you have any idea why that happened? I have been using these macros for 10 years, and this is the first time that they disappeared like that. Could it have been the crashs of LO that I mentioned in the original post?

Thanks again!

Weird, same with me. My library vanished from LO. Edited script.xlc and its back. Many thanks.