[Solved] Macro - One button changes the other button

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
josecarvalho
Posts: 6
Joined: Thu Nov 30, 2017 7:43 pm

[Solved] Macro - One button changes the other button

Post by josecarvalho »

Hello everybody!
I'm, trying to make a quiz game in calc, and would thank all the help I can get.
To put it simply:

I have a dialog box with two action buttons (A and B)

the label's value of A and B, is retrieved each from cells C and D respectivelly

when I press one button, and if the answer is true, the values of cells C and D are regenerated randomly (using calculateAll)

I would like that, as soon as the value of cells C and D are regenerated, the labels of buttons A and B would also change imediatelly to the new C and D values


I managed to make that happen with a macro in button A, but button B does not change its label... :knock: Wow can I solve it ?
Last edited by Hagar Delest on Tue Jan 23, 2018 12:15 am, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 5.4.3.2 on windows XP and win10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: macro - One button changes the other button

Post by Villeroy »

Similar topic: viewtopic.php?t=87732
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
josecarvalho
Posts: 6
Joined: Thu Nov 30, 2017 7:43 pm

Re: macro - One button changes the other button

Post by josecarvalho »

Many thanks. I'll see if that helps !
OpenOffice 5.4.3.2 on windows XP and win10
josecarvalho
Posts: 6
Joined: Thu Nov 30, 2017 7:43 pm

Re: Macro - One button changes the other button

Post by josecarvalho »

I'm back ... the file Villeroy directed me to was helpful to some extent. I could make one button change the other, but I could not make it work with more buttons, as I wished, because the code is not clear for me, as a beginner, in the way it refers to each button. :?

In the attached file there's an example of what I want to do. It's a little quiz engine. In this example, I can make it work almost the way I wanted to.

If you open the file, you see the question in green, and then you have the cells with the 5 possible answers, each with the respective button at its right.

If you choose a wrong answer, the button label changes to "X"; If you choose the right answer, it generates another question. - That works !

The problem is, if you click on any wrong answer, the "X" will stay in the button, even after you click on the right answer.

What I wanted to happen is : after you choose the right answer, the "X" on the "wrong" buttons would disappear. That should be simple, right ? - not for me ! :crazy:

Will thank any help ! :D
Test 1.ods
here's the file
(15.49 KiB) Downloaded 163 times
OpenOffice 5.4.3.2 on windows XP and win10
josecarvalho
Posts: 6
Joined: Thu Nov 30, 2017 7:43 pm

Re: Macro - One button changes the other button

Post by josecarvalho »

Here I am again.
Thanks, Villeroy, for the link you sent, it was helpful.
The code might not be pleasant to watch, but after long hours of hard work and study, somehow I made it work the way I wanted.
See you next time !
OpenOffice 5.4.3.2 on windows XP and win10
Post Reply