InDesign find and replace

I’ve been sucessful in scripting a find and replace in InDesign, but would now like to use a variable instead of just a hard-coded string.

Specifically, i want to replace instances of “!!!DATE!!!” found in the InDesign document with a date variable that will produce the next day’s date (i.e. “Tuesday, January 12, 2005” when the actual date is mon. 1/11/05).

How can I have AppleScript calculate tomorrow’s date and convert it to a text string that can be used in the substitute_text() command?

Thanks in advance!

The script as is:

(*  clear InDesign's find/change preferences  *)
tell application "Adobe InDesign CS2"
	set find preferences to nothing
	set change preferences to nothing
end tell

get current date
tell (current date)
	set currentDay to day
	set currentMonth to month of it
end tell

(* search and replace data *)
substitute_text("!!!DATE!!!", "DATE VARIABLE", true, false)

display dialog "Finished cleaning text."

 * substitute_text()
on substitute_text(findItem, replaceItem, withRepeat, asWord)
	tell application "Adobe InDesign CS2"
		if (count documents) > 0 then
			set myDocument to active document
			if asWord is true then -- replace word
					set (every word of every story of myDocument whose contents = findItem) to replaceItem
				end try
			else -- search and replace text
				set finishedReplace to false
				repeat until finishedReplace is true
					tell myDocument
						set replacedItems to search story for findItem replacing with replaceItem
					end tell
					if number of items in replacedItems is 0 or withRepeat is false then set finishedReplace to true
				end repeat
			end if
			display dialog "You do not have a document open."
		end if
	end tell
end substitute_text

Try this:

set tDate to date string of ((current date) + 1 * days)

Hope this helps,
Brad Bumgarner, CTA

Perfect. Thanks!