Please enable JavaScript to view this site.


Navigation: Tokens > Macro Tokens

Macro Colors

Scroll Prev Up Next More

You can use macros to vary the appearance of one or more colors of your template based on the date of any token.


This is very useful in scholastic diaries where each month often uses a totally different palette of colors.


To use variable colors, in your QuarkXPress or InDesign template, define one or more macro colors named with names of the form:




where XX represents any number from 01 to 30 (2 digits), corresponding to the range of allowed macro index values, and AnyName is a name of your choosing (such as WinterHeader).


Then, whenever one of these macro colors is selected in macros or as text formatting, the macro of index XX of the color name will be evaluated, and the color actually used will be the value of the sResult coming from that macro's evaluation.


Macro colors can be used everywhere where you would use one of the colors defined in your template, including as one of the template colors, except in Saras (macros are performed based on the date of a token, and Saras have no relation to dates).


Detailed example


In a diary, we want the dates represented by the tokens [d] , [Dddd] and [Mmmm] to appear in different colors based on which season the token is in (spring, summer, autumn and winter).



In your QuarkXPress or InDesign template, define the macro color C*11_Seasons. Here, we use macro *11, but we could have used any valid macro index from *01 to *30.


The appearance of this color is not important, as it is only a place holder and will never displayed as defined in the template.


In your template, define the 4 colors to use, depending on the season.


In the example on the right, we have named the 4 colors Spring, Summer, Autumn, and Winter, to make it easier to refer to them later, in the macro we use to determine which color to use, based on the date of a token.


But we could have used any name, such as the Pantone color name which cannot be modified in InDesign.


In your template, add a macro index to any token whose color will need to change depending on the season.


Here, in the example on the right, we used macro *1, but we could have used any valid macro index from *01 to *30, as long as it was different from the macro index used for the macro color (*11 in the present example).


Note that the indices of the color macros (*11 in the present case) do not appear in any of the tokens.


After scanning your template, there are 2 messages related to the macro indices specified above.


We begin by specifying the macro for the *11 macro color.


The important aspect of any macro used for macro colors, as in the example below, is that it should return as sResult the exact name of a color as it is defined in your template, and bResult as true.

    bResult = true
    nSeason = SeasonOf(n_TokenDate, 1true)
    switch nSeason
        case 1
            sResult = 'Spring'
        case 2
            sResult = 'Summer'
        case 3
            sResult = 'Autumn'
        case 4
            sResult = 'Winter'
            sResult = 'Paper'


For the resulting actions of the macro used for a macro color, we keep the default options, as shown on the right.


Note that any other group of resulting actions settings, such as Style, Font, Paragraph and Textbox, will be ignored for a color macro.


The only purpose of a color macro is to obtain a color name based on the date of a token.


We can now use the macro color(s) as any other color, once we have specified the macro to use for all the macro colors of our template (only one in the present example, but you can have as many macro color as you want).


We specify that the *1 macro should use the always true macro, as shown in steps 1 and 2 on the right.


Then we specify that the resulting action should be to change the text color to the color C*11_Seasons, as shown in step 3 on the right.


Once you generate the script you can see below that the tokens shown in step 3 change color based on the season of their date, as per the colors defined in step 2.


Remember that macro colors are a way to define colors dynamically (based on the date of each token), but that they do not necessarily imply the use of further macros to be able to use them.


Macro colors can be used everywhere where you would use one of the colors defined in your template, except in Saras.


Topic 181125, last updated on 16-Jun-2023