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.
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:
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??
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
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
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
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.
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