Password for macros that allow the code to run but not to access macros?

I want to protect the macro using a password, I managed to do that but the problem is the macros will not work unless I enter the password , is there a way to unprotect the macro inside the code so that my button function work and in the same time I don’t have to enter a password?

I managed to do that but the problem is the macros will not work unless I enter the password

So how exactly did you manage to do that?

In Standard Library does not work, create a custom library.

And with VBA neither.

I followed your solution but when I got to the Libraries Tab the password button remained “greyed” out and would not respond. Any suggestions?

Standard library can’t be password-protected.

To set password to macros in the way that you require, you need to password-protect the macro library (ToolsMacrosOrganize MacrosBasic; click Organizer; in LibreOffice Basic Macro Organizer dialog, go to Libraries tab, and use Password button).

But be aware of existing bug that prevents using Unicode text (in encoding different from current system’s) with such macros (until the password is entered): tdf#57113.

Actually I did that , somehow macros doesnt work in the sheet unless I enter password ,I want it to work in the background but not to be able to see it I got an error of ’ Une erreur de structure de script s’est produite lors de l’exécution du script vnd.sun.star.script:VBAProject.Feuil5.EnregistrerButtonInitial_Click?language=Basic&location=document en Basic.’

Ah, so you omitted a tiny detail that you are working with some external file format like XLS/XLSX? (not to mention your LO version and OS…) I doubt that LO correctly supports password protection in those filetypes, or in VBA project libraries (even if the file has been saved to ODS, but library type was kept)…

yes I actually did , I used “Option VBASupport 1” and simplified my code to be supported by openoffice ,so that was the issue right ? it doesnt support this kind of types ? thanx…