Change Color Of Text Based On Data In Field Follow

0
Avatar
Legacy Poster

I'm using Bartender Professional and would like to make a script to adjust the color based on field value on each tag.

The database file has multiple vendors and I want them to stand out on the tag being made.

 

I assume going into text properties, data source, transforms, vb Script is where I need to start.  Should the script be under Functions and Subs or OnProccessData.  Tried to use Script Assistant but failed.  

 

Possible text in field is: TOL, UN, LOTUS, NOW.

 

Can I change the border color to make it stand out more?

 

The Colors I would like to use are:

TOL = Blue

UN = Green

Lotus = Purple

Now = Orange

 

Thanks for your time

Robert

7 comments

0
Avatar
Fernando Ramos Miracle
Moderator
Comment actions Permalink

Hello Robert,

 

There are several ways of doing what you are looking for (below you'll find two examples), but unfortunately all of them will require at least the Automation edition as the used features are not supported on the Professional edition.

 

1. If you wish to conditionally change the colour of objects on your documents using a VB Script you would need to use the "Document level VB script", as such properties are only available on that level. This script can be accessed from the "File>BarTender Document Options..." item, under the "VB Scripting" tab.

 

2. A second option would be to set different copies of the same object one on top of the other and "conditionally" print each of them depending on the value from your database (you could also use layers or even templates for this same feature).

 

*As commented above, document level VB script, conditional printing, layers and templates are all features that require the Automation edition.

 

Regards.

0
Avatar
Legacy Poster
Comment actions Permalink

Thanks for the response.  What is the VB Script option used for in the Transforms Tab Used for?(Found under text box properties Data Source)

0
Avatar
Fernando Ramos Miracle
Moderator
Comment actions Permalink

Hello Robert,

 

The "OnProcessData" VB script can modify the value of the data source over which it's applied or even other named data sources in the document, but won't be able to affect in any way the object containing that data source (or other objects for that matter). Label format object properties can only be modified form the "Document Level VB script".

 

Regards.

0
Avatar
Legacy Poster
Comment actions Permalink

Fernando. Do you have a small example of how to do this. I know it can be done but I can get the syntax right.

 

It starts with OnNewRecordEvent. I can't get it to work.

0
Avatar
Legacy Poster
Comment actions Permalink

I'd like to do a similar thing to change the text colour of multiple text objects on a label.

A segment of example code would really help as I am also struggling to understand from the help how i need to reference the text objects that i want to change the text colour on.

 

I am assuming i need to use this to set the text colour?

 

X = F26531
Format.Objects(«object name or index»).TextColor = X
 

But i am not sure what to input as the object name. I tried inputting the name of an object from the Data Sources -> Object values pane but that seems to be incorrect. I'd want to be able to define a number of different elements on the label to change the text colour for. It'd be even better if i could optionally target a substring format.

0
Avatar
Legacy Poster
Comment actions Permalink

The code needs to be under File > BarTender Document Options > VB Scripting

The object's name must be in double quotes ( Format.Objects("myobject").TextColor = Red ). I'm not sure you can use "F26531" as color, but I'd say there is at least a chance to make it work.

I don't think you can change individual substrings' formatting...

0
Avatar
Legacy Poster
Comment actions Permalink

Thank you so much! That worked perfectly and is going to save hours of re-colourizing label elements in seasonal changes!

Please sign in to leave a comment.