Open Document Dialog - Indesign.

hi everyone

need to write a script that prompts the user to select from 4 master documents.

the documents would be saved into a single folder on the end users computer.

i would like names of the 4 master documents displayed in the dialog and the user you select and then hit “ok” or cancel

… i am not quite sure how to go about it (i think i am confusing myself because it should be rather simple : )

set myPath to “xxxxxx/yyyy/folder”
tell application “Adobe InDesign CS6”
if button returned of ??? is “filename” then open theDoc

thoughts? ideas? HELP! (lol)

thank you in advance - rick

Hi Rick,

Try this:


tell application "Finder"
	set theMastersFolder to files of folder ((path to desktop as text) & "testMasters")
end tell

set theMastersList to {}

repeat with thisInDDmaster in theMastersFolder
	set theMastersList to theMastersList & (name of thisInDDmaster)
end repeat

set chosenDoc to choose from list theMastersList with prompt "Choose a master doc:"

if chosenDoc is false then
	error number -128
else
	set chosenDoc to chosenDoc's item 1
end if

set thisFilePath to ((path to desktop as text) & "testMasters:")

tell application "Adobe InDesign CS6"
	activate
	set user interaction level of script preferences to never interact
	open (thisFilePath & chosenDoc)
	set user interaction level of script preferences to interact with all
end tell

You’ll need to create a folder on the desktop called testMasters and put your master files in there.
The script allows for any number (apart from 0) of master docs in the folder.
I’ve tested this in CC 2015 and it works ok.

HTH

Hi. I would add emphasis to the fact that what you were originally requesting is not directly possible with AppleScript, because there is a three-button limitation in dialogs, which includes Cancel/OK. You’ll find an essential reference here:

https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html

ok tecnick - i will give it a try! thank you!

marc anthony - would it be possible to set up “toggle select” ex: displays the name of the documents and the user selects the one he wants to open then ok or cancel??

thank you again rick

Hi Rick,

When you talk of ‘toggle select’ are you talking about checkboxes, radio buttons, dropdowns etc?

Thanks

well after i was able to get the script working…i answered my own question lol

yes the script lists the available documents and prompts “choose”

thank you!!

now i just have to figure out how to integrate it into indesign :frowning:

i created an event listener script and put it into the indesign start up script folder. it does work but creates a generic document and opens a master doc

tell application “Adobe InDesign CS6”
set myEventNames to {“afterNEW”}
repeat with myEventName in myEventNames
make event listener with properties {event type:myEventName, handler:“Macintosh HD:Applications:Adobe InDesign CS6:Scripts:Scripts Panel:Samples:AppleScript:masterFILE_OPEN”}
end repeat
end tell

according to CS5 documentation there is a beforeNEW event listener but i haven’t been able to make it work in CS6

my objective: on new document the end user would be prompted to open a master document. if user did not want to open a master document then the script would return to the new document setup. does that make sense lol

ok there is “beforeNew” and “afterNew” event listener but it yields the same result. it creates a “generic” document as well as opening a master doc.

TOL i guess what the script is missing is something that deletes the resulting “generic document” or ignores the document setup on new>document … if>then>else

if a master doc is selected/ok

then cancel new document setup

if a master document isn’t selected/cancel

then return to new document setup

…not sure how to write that :frowning:

Bit of a tricky one this.

I’ve tried using the beforeNew and afterNew event listeners to achieve this.

It appears that everything you’ve told InDesign to do, in the event listener, gets executed and then InDesign gets back to what it was doing. In this case it’s creating the new document.

You need something to kick in after the new ‘untitled’ document has been created and that appears to be after the event listener has finished.

Not sure if someone else might be able to help?

you are correct. beforeNew or afterNew runs the script and basically interrupts the create new document process.

(using afterNew) the user creates new> document. the default indesign document creation dialog appears. user presses ok>the script runs and new dialog appears prompting the user to select (or not) a master doc. and press ok or cancel. pressing cancel returns CS6 to the document creation process and creates a doc.

if the the user creates new document and then cancels nothing happens

too bad there wasn’t an “afterCancel” listener lol

TOL i wonder the script could be written …so that…if two documents were created the script would automatically “whack” the last document created in the process (without interaction). the last document is always the result of default process.

that doesn’t help if the user wants to use the default document creation process