How can I make a macro exclusive to one spreadsheet

I have a large spreadsheet and over the years I have developed a series of macros using BASIC to ease the entry and retrieval of data. However if I load other spreadsheets they detect the presence of these macros and mainly because the sheet automatically runs a macro when loading can give error messages which are not relevant. I am sure there must be a way of isolating macros so that they are only visible to the application for which they are intended. Can anyone help me out with this please.

You need to save the macro in your document instead of LibreOffice. Then the macro will only be available when you load that document.

Thanks for your interest it is much appreciated. I was under the impression that macros are automatically saved when saving the document. I have also saved the Basic manually, directly from the macro editor. The current folder is “my macros & dialogues”> “Standard” > “Module1”. I notice that there is a folder with the same name as “my document” which contains a sub folder called “Standard” Do I need to save the macros in this folder and if so will my document find the basic automatically?

Yes, save it in the Standard folder of your document. When you save the macro to this folder, LibreOffice will create a new module and ask you to name it (Module1 is the default name). Your macro will be saved in Standard > Module1. It will be found by LibreOffice because it is saved inside the spreadsheet file. Some issues: In my testing, even though I gave a macro a specific name, it still is named Main. I found no way to move a macro from LibreOffice to a document. So you may have to save the macro to your spreadsheet and after you’re sure it works, remove the macro from the LibreOffice folder so it’s not used in other documents.

Thanks again, I will do this as soon as I get a few minutes to spare.

I eventully managed to move my macros (there are many of them so a single macro called “main” will not work) into the" MyDocument"> Standard> Module1 folder. Not a straightforward process, I had to copy and paste. The “Save As” option was greyed out. “MyDocument” insists on looking in the original location in the MyMacros & Dialogues folder. I guess I did not find the correct method to transfer the basic. Is there a way of pointing “MyDocument” to the correct folder?