[Solved] Change properties of Calc Push Button using macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Locked
Nocton
Volunteer
Posts: 533
Joined: Fri Nov 05, 2010 10:27 am
Location: UK

[Solved] Change properties of Calc Push Button using macro

Post by Nocton »

On sheet named 'Sheet1', I have a Push Button named 'Switch' with Label 'ON' and font colour green. After the button's action is executed I want to change it to 'OFF' and Red.
What is the best way to do that?
Last edited by Nocton on Wed Dec 06, 2023 8:06 pm, edited 1 time in total.
OpenOffice 4.1.12 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11495
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Change properties of Calc Push Button using macro

Post by Zizi64 »

Here is a sample file with an embedded macro.
ButtonProperties.ods
(10.14 KiB) Downloaded 551 times
Modified sample: I just deleted two helper Print commands.
Last edited by Zizi64 on Wed Dec 06, 2023 8:44 pm, 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.
Nocton
Volunteer
Posts: 533
Joined: Fri Nov 05, 2010 10:27 am
Location: UK

Re: Change properties of Calc Push Button using macro

Post by Nocton »

Thank you Zizi64 - a nice solution.
OpenOffice 4.1.12 on Windows 10
qqaazz8
Posts: 2
Joined: Thu Sep 04, 2025 1:53 pm

Re: Change properties of Calc Push Button using macro

Post by qqaazz8 »

Zizi64 wrote: Wed Dec 06, 2023 6:32 pm Here is a sample file with an embedded macro.

ButtonProperties.ods

Modified sample: I just deleted two helper Print commands.
What is the code for "Additional information" ?
OpenOffice 4.1.15 on Windows 11
User avatar
karolus
Volunteer
Posts: 1234
Joined: Sat Jul 02, 2011 9:47 am

Re: Change properties of Calc Push Button using macro

Post by karolus »

qqaazz8 wrote: Thu Sep 04, 2025 2:01 pm
What is the code for "Additional information" ?

Code: Select all

msgbox oButton.Tag
Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (Bookworm) (on RaspberryPI5)
User avatar
Zizi64
Volunteer
Posts: 11495
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: [Solved] Change properties of Calc Push Button using macro

Post by Zizi64 »

Use one of excellent object inspection tools: MRI and XrayTool

Usage of them - inside the macro code - will list all existing properties and methods (and others) of the programming objects:

Code: Select all

xray oButton

mri oButton
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.
qqaazz8
Posts: 2
Joined: Thu Sep 04, 2025 1:53 pm

Re: Change properties of Calc Push Button using macro

Post by qqaazz8 »

karolus wrote: Thu Sep 04, 2025 5:18 pm
qqaazz8 wrote: Thu Sep 04, 2025 2:01 pm
What is the code for "Additional information" ?

Code: Select all

msgbox oButton.Tag
Thanks.
OpenOffice 4.1.15 on Windows 11
Locked