Page 1 of 1

Change text color of Calc form control with macro

Posted: Wed Nov 17, 2010 8:43 pm
by skradus
I'm trying to write a Basic macro that changes the text color of a form button in Calc (v. 3.2.0 for Ubuntu 10.04.1) when the user clicks on the button.

The Control Element Forms reference at http://wiki.services.openoffice.org/wik ... ment_Forms lists a TextColor (long) property, which it defines as "text color of control element." I'm guessing that this is what I am looking for. However, when I write:

Code: Select all

Sub ButtonClick(oEvent)
Button = oEvent.Source
Button.TextColor = RGB(255,255,255)
End Sub
assign ButtonClick to the button, and press the button, Calc returns the error: "BASIC runtime error. Property or method not found: TextColor." I have also tried CharColor, but that gives the same result.

Can anyone tell me what I am doing wrong?

Many thanks,
skradus

Re: Change text color of Calc form control with macro

Posted: Thu Nov 18, 2010 9:12 am
by B Marcelly
Hi,
The Basic Guide wrote:The model object of a form button provides the following properties:
The Source property of an event provides the view of the control. You have to get the model from the view.

Code: Select all

Button = oEvent.Source
Button.Model.TextColor = RGB(255,255,255)
Yes, that is not obvious from the Basic Guide pages...

Re: Change text color of Calc form control with macro

Posted: Thu Nov 18, 2010 3:25 pm
by FJCC
This is a an excellent example of why you should get an object inspection tool like xray.

Re: Change text color of Calc form control with macro

Posted: Fri Nov 19, 2010 2:35 am
by skradus
Brilliant. Thank you.