[Solved] Macro function in Calc OpenOffice

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Kusk
Posts: 5
Joined: Mon Dec 16, 2019 9:55 am

[Solved] Macro function in Calc OpenOffice

Post 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..?
Last edited by Hagar Delest on Mon Jan 15, 2024 2:37 pm, edited 1 time in total.
Reason: tagged solved.
OpenOffice 4, win10
AndrOpen, Android Lenovo Tablet
User avatar
Zizi64
Volunteer
Posts: 11364
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Macro function in calc openoffice

Post by Zizi64 »

We can not guess the solution without a sample file and the embedded macro code...
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Kusk
Posts: 5
Joined: Mon Dec 16, 2019 9:55 am

Re: Macro function in calc openoffice

Post 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
Attachments
Efterkalk_Android.ods
(27.69 KiB) Downloaded 305 times
OpenOffice 4, win10
AndrOpen, Android Lenovo Tablet
User avatar
Zizi64
Volunteer
Posts: 11364
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Macro function in calc openoffice

Post 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.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
Posts: 11364
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Macro function in calc openoffice

Post 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
Last edited by Zizi64 on Mon Jan 15, 2024 9:52 am, edited 1 time in total.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Kusk
Posts: 5
Joined: Mon Dec 16, 2019 9:55 am

Re: Macro function in calc openoffice

Post 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
OpenOffice 4, win10
AndrOpen, Android Lenovo Tablet
Post Reply