Copy link to clipboard
Copied
Is it possible to add a text variable and set all options via js?
var myV = app.activeDocument.textVariables.add({name: 'TCD', variableType: VariableTypes.MATCH_CHARACTER_STYLE_TYPE});
myV.preferences.searchStrategies = SearchStrategies.LAST_ON_PAGE;
myV.searchStrategies = SearchStrategies.LAST_ON_PAGE;
The second and the third line don't work. Is it possible to set the options like search strategies, characterStyle, text after & before etc. via script?
MatchCharacterStyleType is read only.
Copy link to clipboard
Copied
Hi @mateuszp13156491, you need to set the variableOptions of the textVariable, which in this case will be a MatchCharacterStylePreference object. So use this in your code:
myV.variableOptions.searchStrategy = SearchStrategies.LAST_ON_PAGE;
- Mark