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

change text color with code

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
checoturco
General User
General User


Joined: 03 Nov 2008
Posts: 8

PostPosted: Tue Nov 04, 2008 4:52 am    Post subject: change text color with code Reply with quote

Hi all,

i've been looking in this forum one way to change the color of text in a textBox depending on the word that this textbox receives.

MAybe i'm wrong but i think that i jsut need the right merthod to do that....i have this

ThisComponent.Drawpage.Forms.getbyname("MainForm").getByName("Sp1").FontColor=116711680

where the 116711680 is the color which i need.

Many tkanks,

Checo
Back to top
View user's profile Send private message
brian4m
OOo Enthusiast
OOo Enthusiast


Joined: 13 Feb 2006
Posts: 162
Location: Bath, England

PostPosted: Tue Nov 04, 2008 10:37 am    Post subject: Reply with quote

There is a database, Product stand2, which I am currently studying, which has a solution to that problem. There are different colours for Unpaid and Paid. The macro is Find Color.

The thread is http://www.oooforum.org/forum/viewtopic.phtml?t=72062

Thanks to VooBase for that very good example of a database and associated macros. For a beginner like me it is a great help.

Brian
PS. I forgot to state it is the form Asset Movement.
Back to top
View user's profile Send private message
checoturco
General User
General User


Joined: 03 Nov 2008
Posts: 8

PostPosted: Wed Nov 05, 2008 12:19 am    Post subject: Reply with quote

thanks for your answer Brian4m,

I download the database and when i check the macros for this DB, no macros exist.
Maybe i'm doing something wrong... i'm new with the sBase ( i started last week)....
Can you please put here the macro code.

Tks,

Checoturco.
Back to top
View user's profile Send private message
probe1
Moderator
Moderator


Joined: 18 Aug 2004
Posts: 2560
Location: Chonburi Thailand Asia

PostPosted: Wed Nov 05, 2008 5:44 am    Post subject: Reply with quote

checoturco,

macros attached to a BASE document exists since V3.0.0


If you are (still) using OOo 2.4.x there will be no macros...
HTH
_________________
Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs
Back to top
View user's profile Send private message Visit poster's website
checoturco
General User
General User


Joined: 03 Nov 2008
Posts: 8

PostPosted: Wed Nov 05, 2008 8:53 am    Post subject: Reply with quote

i Had the version 2.3.... i already update for version 3.0

Now works fine what i wanted... i just had to change the backgroundcolor by textcolor.

Thks all.

Checoturco
Back to top
View user's profile Send private message
Voobase
OOo Advocate
OOo Advocate


Joined: 21 Nov 2007
Posts: 400
Location: Australia

PostPosted: Sat Nov 08, 2008 6:03 am    Post subject: Reply with quote

Hi Checo,

Quote:
I download the database and when i check the macros for this DB, no macros exist.
Maybe i'm doing something wrong... i'm new with the sBase ( i started last week)....
Can you please put here the macro code.


Regarding the macro code for that example, it is not embedded into the database file or within the forms. If you look in the zip file there is a folder called "Asset_Example". The macro file is inside that in a file called "script". The macro file will need to be imported into "Open Office" itself. To do this go to Tools>Macros>Organise Macros>OpenOffice.org basic (or just press ALT F11) then Organized>Libraries>Import and choose the script file. You will also need to "register" the database. There are some instructions for doing this in the post that goes with the example.

Macro files were one of the cumberson things with Base and until recently, there were only two ways to deal with them. The way I preferred was to install the macro file on each computer that you wanted to use the database with. Otherwise you could embed the macro file in a "writer doc" form, but then you get the "macro warning" message each time you wish to load the form and it was harder to share the macros between each of your "writer doc" forms.

What Probe1 is referring to is that there is now a third way to transport your macro file, since the recent release of OO V3.0 Now you can embed it into the database file itself. I haven't tried doing this yet but it sounds like a good thing.

Regarding setting the color of text in a textbox, you would use a line like this...
ThisComponent.Drawpage.Forms.getbyname("MainForm").getByName("Sp1").TextColor = RGB(0,135,250)

In the macro that Brian referred to (find color), it uses "case" to determine which color to use for which word. This is sort if like using several "IF" statements cascaded together.

Cheers

Voo
Back to top
View user's profile Send private message
checoturco
General User
General User


Joined: 03 Nov 2008
Posts: 8

PostPosted: Fri Nov 14, 2008 8:06 am    Post subject: Reply with quote

Hi Voo,

yes, indeed i saw the code after i put my post asking for the code.
I saw the .xbl files but i didn't know that these files have the code, (indeed i don't know why they have this extension, i'm trying get more information...) but i open them with the notepad and i saw the macros code, i copy my text from here.

Concerning the macros, i have the same problem in decide if i put the code inside or outside the form, every time that i open the form i get an error and i read that this error is due the code be inside the form and the objects are not loaded yet, if i close the form and i open it again, the error dissapear.....

Well, i begin with the sBase a few days ago and i'm trying to understand some things,

Tks,

Checo.
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 Base 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