Page 1 of 1

[Solved] Macro function in Calc OpenOffice

Posted: Sun Jan 14, 2024 11:47 am
by Kusk
Hey
I have created a function in a calc macro, openoffice, that when cell B2 is changed, the function is either true/false, it works perfectly, but..
When the spreadsheet is closed down and reopened, it writes in the cell where the function is called (=MYPROCEDURE(B2)) "Nothing to do.." and the function does not work, but if I reopen macro and remove the protection, the function works again..?

Re: Macro function in calc openoffice

Posted: Sun Jan 14, 2024 11:52 am
by Zizi64
We can not guess the solution without a sample file and the embedded macro code...

Re: Macro function in calc openoffice

Posted: Sun Jan 14, 2024 12:20 pm
by Kusk
Here is my calc and It's all in danish, but I'll believe you'll figure it out
The code for the macro is 2851 and dont let you comfuse at Android, it's not for Android (just a name)

thanks in advance
palle

Re: Macro function in calc openoffice

Posted: Sun Jan 14, 2024 12:26 pm
by Zizi64
When the spreadsheet is closed down and reopened, it writes in the cell where the function is called (=MYPROCEDURE(B2)) "Nothing to do.." and the function does not work,
Because only the Standard directory will be loaded automatically into the memory when you launch the Calc. You must load all of others before you want to use the procedures and function located in them.

Re: Macro function in calc openoffice

Posted: Sun Jan 14, 2024 2:54 pm
by Zizi64
...But the Calc custom Cell Functions will work from the Standard Library only. And your MyProcedure() is a Function really, but not a Sub. (And you can not Call a Sub from a cell.)

Here is a code for loading the Kalk library from the macro container of the FILE:

Code: Select all

Sub LoadKalk()
	If NOT ThisComponent.BasicLibraries.isLibraryLoaded("Kalk") Then
		ThisComponent.BasicLibraries.loadLibrary("Kalk")
	End If
End sub

Re: Macro function in calc openoffice

Posted: Tue Jan 16, 2024 12:30 pm
by Kusk
Zizi64 wrote: Sun Jan 14, 2024 2:54 pm ...But the Calc custom Cell Functions will work from the Standard Library only. And your MyProcedure() is a Function really, but not a Sub. (And you can not Call a Sub from a cell.)

Here is a code for loading the Kalk library from the macro container of the FILE:

Code: Select all

Sub LoadKalk()
	If NOT ThisComponent.BasicLibraries.isLibraryLoaded("Kalk") Then
		ThisComponent.BasicLibraries.loadLibrary("Kalk")
	End If
End sub