Skip to main content
Participant
June 7, 2024
Question

Make Text Variables 1 Year In Advance (Expiry Date)

  • June 7, 2024
  • 1 reply
  • 364 views

Hello. Does anyoe know a way to put the text variables 1 year in advance. So everyday I open indesign, the date has changed with a +1 year. 07-JUN-2025

This topic has been closed for replies.

1 reply

brian_p_dts
Community Expert
Community Expert
June 7, 2024

Make a custom text variable called "oneyeardate". Then, run this script when you open the doc:

var d = new Date();
var day = ("0" + d.getDate()).slice(0,2);
var month = ("0" + d.getMonth() + 1).slice(0,2);
var nextyear = d.setFullYear(d.getFullYear() + 1);
app.activeDocument.textVariables.itemByName("oneyeardate").customTextVariablePreferences.contents = month + "-" + day + "-" + nextyear;
Peter Kahrel
Community Expert
Community Expert
June 11, 2024

For customTextVariablePreferences use variableOptions instead.