I have a strange issue with setting the page orientation of a new document in InDesign CS5.5.
In CS5 I used the following script:
tell application "Adobe InDesign CS5"
set vTemplate to make new document
tell vTemplate
set page orientation of document preferences of active document to landscape
end tell
end tell
But the same script in CS5.5 gives an error:
"Adobe InDesign CS5.5 got an error: Can’t set page orientation of document preferences of active document of active document to landscape."
Can somebody pint me in the right direction?
Thanks!
It looks to me like it should error; I would wonder why it works in any version. I think this line:
set page orientation of document preferences of active document to landscape
should be:
set page orientation of document preferences to landscape
Since that line is in a tell block, the of active document is redundant—you're telling the document object already.
Jeff
Hi Jeff,
You are right, it was one of many tries and unfortunately I used this one...
But also your suggestion gives the same error: "Adobe InDesign CS5.5 got an error: Can’t set page orientation of document preferences of active document of active document to landscape."
Did you by any chance try the code on your system, do you (or anyone) have anymore suggestions?
Tnx
Ton
this gets stranger by the minute...
I'm using 10.6.8 as well, but even setting the default preferences doesn't work.
The following should set the page orientation of each new document, but it gives the same error:
tell application "Adobe InDesign CS5.5"
set page orientation of document preferences to landscape
end tell
You have now lost reference to both document objects… What works is…
tell application "Adobe InDesign CS5" -- issue commands to indesign
set vTemplate to make new document
tell vTemplate -- issue commands to the newly created document
set page orientation of document preferences to landscape
end tell -- end commands to document
end tell -- commands to indesign
Yes, CS5 works, but CS5.5 doesn't—but not in the way Tony originally posted!
FWIW, the equivalent assignment in JavaScript:
app.activeDocument.documentPreferences.pageOrientation = PageOrientation.LANDSCAPE;
works in CS5.5 as expected. I really don't know Applescript—I just saw what looked like a pretty clear-cut error in Tony's code—are there other ways to refer to these enumerator objects in it?
AppleScript is typically fairly forgiving in its parameters, so you could try both the value 2003395685 and the string 'wide' it represents (see http://jongware.mit.edu/idcsjs5.5/pe_PageOrientation.html).
I agree this would indicate some sort of bug in the scripting interface.
I use AppleScript far less than I used to a couple of years back… I answer the odd post here because help with AppleScript is not as readily available. I recall the some of the syntax thou… I don't think there is anything that could be done from the user point of view it's down to the app's scripting terminology when you compile the code 'landscape' is NOT a variable its a recognised application term… It will get some >>blah<< identifer behind the scenes so to speak… AppleScript became a PITA when dealing with ibm/intel macs/apps using the ESTK has meant I avoided this…
The problem is essentially a bug introduced in 5.5. Basically, the dictionary uses the terms "portrait" and "landscape" in two places, with different underlying codes.
The offending terminology relates to the "set folio orientation" command, which defines landscape as «class eIOh», as opposed to the original definition of «class wide».
Anyway, the solution is to use something like this:
set page orientation of document preferences to «class wide»
Feel free to log it as a bug.
absqua wrote:
Would you care to explain, Shane, how you go about discovering those underlying <<class>> identifiers?
I use Script Debugger, which has an option to show them (View -> Show Raw (Chevron) Syntax) .
You can also see them if you open the dictionary in AppleScript Editor, choose Save As, and save as an .sdef file. That's an XML file you can look at in a text editor. But it's very tedious, especially for something with a big dictionary like ID.
Thank you Shane. I've seen the chevrons pop up in compiled Applescripts before but have never invested the time to learn how to track them back to the “regular” identifiers.
Poking around a bit, it looks like Apple also provides a command-line tool, sdef, to dump them:
sdef /Applications/Adobe\ InDesign\ CS5.5/Adobe\ InDesign\ CS5.5.app | xmllint --format - | grep landscape
as a quick-and-dirty way to get those of us without Script Debugger at least sort of into the general vicinity.
@ absqua - Thanks for this!
app.activeDocument.documentPreferences.pageOrientation = PageOrientation.LANDSCAPE;
When the totally green newbie JS student (like me) tries to follow a tutorial, say for example like the DocumentTemplate tutorial script beginning on the bottom of page 29 in Adobe InDesign CS6 Scripting Tutorial, and who unknowingly, but mistakenly thought something as benign as following sundry script examples, etc. (because they're working with many windows open) would best be facilitated with a default document in LANDSCAPE orientation, this little line of code will overtly address the problem created by the tutorial script writer who similarly and unknowingly, but mistakenly thought something as benign as orientation would not coyly gum up the works.
You helped fix that problem
and I thank you very much!
Kind regards,
Kelly
North America
Europe, Middle East and Africa
Asia Pacific