| View previous topic :: View next topic |
| Author |
Message |
checoturco General User

Joined: 03 Nov 2008 Posts: 8
|
Posted: Tue Nov 04, 2008 4:52 am Post subject: change text color with code |
|
|
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 |
|
 |
brian4m OOo Enthusiast

Joined: 13 Feb 2006 Posts: 160 Location: Bath, England
|
Posted: Tue Nov 04, 2008 10:37 am Post subject: |
|
|
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 |
|
 |
checoturco General User

Joined: 03 Nov 2008 Posts: 8
|
Posted: Wed Nov 05, 2008 12:19 am Post subject: |
|
|
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 |
|
 |
probe1 Moderator


Joined: 18 Aug 2004 Posts: 2478 Location: Chonburi Thailand Asia
|
Posted: Wed Nov 05, 2008 5:44 am Post subject: |
|
|
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 |
|
 |
checoturco General User

Joined: 03 Nov 2008 Posts: 8
|
Posted: Wed Nov 05, 2008 8:53 am Post subject: |
|
|
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 |
|
 |
Voobase OOo Advocate


Joined: 21 Nov 2007 Posts: 400 Location: Australia
|
Posted: Sat Nov 08, 2008 6:03 am Post subject: |
|
|
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 |
|
 |
checoturco General User

Joined: 03 Nov 2008 Posts: 8
|
Posted: Fri Nov 14, 2008 8:06 am Post subject: |
|
|
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 |
|
 |
|