OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Formating a SpreadSheet Background

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
JZA
OOo Advocate
OOo Advocate


Joined: 01 Feb 2003
Posts: 432
Location: Mexico

PostPosted: Fri Jun 08, 2007 11:37 pm    Post subject: Formating a SpreadSheet Background Reply with quote

I want to know how can I select a row and format the background from OOoBasic. So far the Macro recorder doesn't seem to pick up when I select the row.

I need to:
a) select a row
b) specify the background color
c) loop the process every other row.

I guess the double loop is not an issue, however I want to know how to select the row and specify the background color.
_________________
Alexandro Colorado
PPMC Apache OpenOffice
http://es.openoffice.org
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
squenson
Super User
Super User


Joined: 09 Mar 2007
Posts: 690
Location: Nis, Serbia

PostPosted: Sat Jun 09, 2007 12:27 am    Post subject: Reply with quote

JZA,

You cannot select a row as such, but yo can select all the cells of row 23 with
Code:
oMyCurrentRange = oSheet.getCellRangeByName("A23:IV23")
And then apply the background color you want.

But there are simpler options without a macro to highlight every other row. For example, create a new style, called blue, and give it a blue background, then use a conditional formatting that assigns the blue style for each cell in your entire range:
Code:
MOD(ROW();2)=1

_________________
Help us to help you: Add [Solved] to the title of the thread if you agree with the answer
>>> Do you know the new OOo support forum http://user.services.openoffice.org/en/forum/index.php? <<<
Back to top
View user's profile Send private message
JZA
OOo Advocate
OOo Advocate


Joined: 01 Feb 2003
Posts: 432
Location: Mexico

PostPosted: Sat Jun 09, 2007 1:32 am    Post subject: Reply with quote

I most be doing something wrong I went ahead with the conditional formating however it didnt quite work. What did the MOD(ROW();2)=1 was supposed to go. What does MOD() means, since I am using a spanish version of OOo I need to know the function to find it on the function list.

I did found ROW() btw.

Is this supposed to go on the field for the different conditionals? Thanks.
_________________
Alexandro Colorado
PPMC Apache OpenOffice
http://es.openoffice.org
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
squenson
Super User
Super User


Joined: 09 Mar 2007
Posts: 690
Location: Nis, Serbia

PostPosted: Sat Jun 09, 2007 1:46 am    Post subject: Reply with quote

JZA,

MOD(x, y) returns the remainder after a number x is divided by a divisor y. So, depending on the value of the row number, the formula returns either 0 or 1.

Select your range, then use the menu Format > Conditional formatting
Select Formula is (or Spanish equivalent) is the first combo box, which hides the second combobox and in the text field area put the formula MOD(ROW();2)=1, then select the proper style if the condition is true.
_________________
Help us to help you: Add [Solved] to the title of the thread if you agree with the answer
>>> Do you know the new OOo support forum http://user.services.openoffice.org/en/forum/index.php? <<<
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10065
Location: Germany

PostPosted: Sat Jun 09, 2007 12:32 pm    Post subject: Reply with quote

Run this macro to translate localized formulae to English and back:
http://www.oooforum.org/forum/viewtopic.phtml?t=23270
_________________
Rest in peace, oooforum.org
Get help on http://forum.openoffice.org
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group