Insert text variable in InDesign CS3

Can’t find any examples of this and the script dictionary is typically cryptic.

I wamt to use ID CS3’s built in text variable for file name and modification date. I am creating a page and adding a text box, but I can not figure out the code to insert those variable tags in the text box. I could probably do it with GUI scripting but looking at the scripting dictionary it looks like it should be directly scriptable.

Has anyone done this?

Model: G5
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

I have looked at these tags, briefly, and found it better just to add a text frame at the bottom of the page and then just have applescript tell that frame to set contents to date and filename. It only takes a matter of mere seconds.

I need to create the document and then have that modification date update whenever the file is worked on, so the AppleScript solution won’t work for the mod date. I can use that for the file name though.

Anyone else have any luck adding that mod date variable text??

what about an script inside indesign that you run to save the document, print and make pdf, etc. Then it could insert the modified date.

Yeah, that’s not really practical for our department.

The only “solution” I have is to create a blank document with that tagged box and open that template to start instead of starting with a new document. It would work but it’s annoying that a feature that is obviously scriptable is impossible to figure out as far as syntax.

Any other InDesign CS3 scripters out there who want to give this a shot?

Thanks.

Matt-Boy,
Take a look at page 107 of the “Adobe InDesign CS3 Scripting Guide: AppleScript.” It gives an example of an events listener script that populates a document slug with user name, creation date, etc. A script could be written to handle the info you need and attached to the standard Save command in the InDesign UI. That way, users are automatically running the script every time they save a document without any training issues, or simply forgetting to do it.
:cool:

Mark

I never read that before. It doesn’t look like I can use it as it involves saving that reference script in addition to the main script, but it was pretty interesting.

Thanks for the info.

I am making this work by creating a template that has a text box in position with the mod date tag already in it. The script picks up the template to start instead of starting with a new document. It’ll work for now but I will keep trying to get the variable text tagging to work. I can see using this in other scripts as well if I can get it working.

Model: G5
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Try something like this:


tell text frame TargetFrame to make text variable instance with property "Modification Date"

Thanks for giving it a shot. Still not working though. I tried what you had and a number of variations of that syntax and still nothing.

I’m starting to wonder if there is a bug with this feature…

Nah, there’s no bug - it’s just persnickety.
I tested this, and it works:

tell document 1 of application "Adobe InDesign CS3" to make new text variable instance with properties ¬
	{associated text variable:"Modification Date"} at the first text frame --or wherever

Yes! It works. Here is my final code for what it’s worth.

Thanks again. That’s awesome.

tell application "Adobe InDesign CS3"
	activate
	tell active document
		set horizontal measurement units of view preferences to inches
		set vertical measurement units of view preferences to inches
		
		set TimeDateTag to make text frame with properties {fill color:"None", stroke color:"Black", stroke weight:1, geometric bounds:{8.4, 2.25, 9.0, 5.25}, contents:("")}
		make new text variable instance with properties {associated text variable:"Modification Date"} at TimeDateTag
		
		set properties of (every text of first paragraph) of TimeDateTag to {applied font:("Helvetica" & tab & "Oblique")}
		set properties of text frame preferences of TimeDateTag to {inset spacing:0.0625}
	end tell
end tell

wicked cool. I was trying to do the same thing yesterday and had just about given up! Thanks!