This article will help you create color objects in BarTender that change colors dynamically depending on the data source specified.
BarTender Designer 2021 and later.
Professional edition and above.
BarTender 2021 introduced a color picker tool that allows for easy color management and PANTONE support. Colors can be assigned to Barcodes, Text, Shapes, and Backgrounds.
In many use cases, you may want to dynamically select colors based on the database record that you have selected. This example will create a box that changes color depending on a Color database field.
Preparing Your Database
To use dynamic colors, you will have to create a database field with compatible color values.
Color values can be assigned by Name (Blue), RGB Color (0, 0, 255), or Hex (0000FF).
- Complete List of Supported Colors, including names and Hex Values.
- NOTE: While color HEX values are prefixed with a pound symbol (#), do not place the # in your database. BarTender will only use the six digit HEX number and won't recognize the colors with a pound symbol.
This example uses a Color field and assigned it Hex values.
Excel will recognize and apply colors for some Hex values. Note that this will push the HEX values to the next column. Format the column as text data to prevent this from occurring.
Creating Dynamic Color Objects
- Open BarTender Designer and create a new document.
- Connect your database using the Database Connection Setup.
- Add a rectangle using Create > Shape > Rectangle.
- Double-click the rectangle to open the Box Properties. Select the Line Color and Fill Properties to make color changes.
- Select Set via data source... when opening the color picker tool:
- In the Data Sourced Color window, select Get color from data source:
- Select Data Source. Select Type → Change Data Source Type:
- Choose Type: Database Field
- Under Field Name, choose the field specifying the color. In this case, it is Color.
- Save and close the dialogs. Use the record selection tool at the bottom left of your template to preview the color changes.
Before BarTender 2021, the color picker tool and its database component did not exist. Dynamic color changes could still be accomplished using Layers or VB Scripting, however.
Complete instructions for how to accomplish dynamic color adjustments in BarTender 2016 and BarTender 2019 are available in our Color Coding Your Items informational document.