here’s a quickie that’s really handy for those of you who have to (against your will, obviously) allow other users to access your InDesign files.
this script was created for a publishing workflow where the editors did their thing right in the live files. this meant there was the potential for page elements to be inadvertently moved or resized or whatever. by locking everything in a document we gain peace of mind for both the editors and designers — editors can do their editing, but there’s no danger that they’ll alter the frames themselves.
to start, we need a dialog box so the user can choose to either lock or unlock everything. as always, follow along in applescript editor (found in applications > utilities) or, for older OS versions, script editor (found in applications > applescript) and update the script to your version of InDesign :
tell application "Adobe InDesign CS4" activate set mgDialog to make dialog with properties {name:"Groovy script to either Lock or Unlock everything in a document"} tell mgDialog tell (make dialog column) tell (make border panel) tell (make dialog column) make static text with properties {static label:"What do you want to do? "} end tell tell (make dialog column) set mgLockButtons to make radiobutton group tell mgLockButtons make radiobutton control with properties {static label:"Lock everything", checked state:true} make radiobutton control with properties {static label:"Unlock everything"} end tell end tell end tell set mgResult to show mgDialog if mgResult is true then set mgLock to selected button of mgLockButtons destroy mgDialog else display dialog "OK, fine, see if I care" buttons {"Cancel"} default button 1 end if if mgLock is 0 then my mgLockAll() else if mgLock is 1 then my mgUnlockAll() end if end tell end tell end tell
massive macgrunt fans will understand pretty much all of that because they have paid attention and studied hard throughout all the previous lessons.
the first part creates a nice looking dialog box for our discerning user :
the second part captures the results of the dialog and acts accordingly — either activating one of two subroutines or, just for shits and giggles, displaying a friendly message if the user decides to cancel instead :
unusually, the rest is very simple — these two subroutines just get placed after the last ‘end tell’ :
on mgLockAll() tell application "Adobe InDesign CS4" tell active document set locked of every page item to true set locked of every guide to true end tell display dialog "All items are now locked" & return & return & "" buttons {"Rock On!"} default button 1 giving up after 1 end tell end mgLockAll on mgUnlockAll() tell application "Adobe InDesign CS4" tell active document set locked of every page item to false set locked of every guide to false end tell display dialog "All items are now unlocked" & return & return & "" buttons {"Bonza!"} default button 1 giving up after 1 end tell end mgUnlockAll
now, applescript experts will be able to streamline that script so that it only takes up about half as many lines — but who cares? it works so fast and effectively that it really doesn’t matter.