// InDesign CS3/CS4 JavaScript // by Stephan Möbius // Moves the selected objects to the next higher unlocked layer. // updated Febr.2009 myScriptIDC = "No InDesign documents are open or nothing is selected!"; MTNL_noSel = "Nothing is selected. \nPlease select object and try again."; if ((app.name != "Adobe InDesign") || ((app.name == "Adobe InDesign") && (app.documents.length == 0))) { alert(myScriptIDC); } else if (app.selection.length != 0) { (app.version[0] < "4") ? (app.userInteractionLevel = UserInteractionLevels.interactWithAll) : (app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll); MTNL_myObjects = new Array; for(MTNL_myCounter = app.selection.length-1; MTNL_myCounter > -1; MTNL_myCounter--) { switch(app.selection[MTNL_myCounter].constructor.name) { case "Rectangle": case "Polygon": case "GraphicLine": case "Oval": case "TextFrame": case "Group": MTNL_myObjects.push(app.selection[MTNL_myCounter]); } } if (MTNL_myObjects.length > 0) { for (MTNL_myObjectCounter=0; MTNL_myObjectCounter < MTNL_myObjects.length; MTNL_myObjectCounter++) { MTNL_myObject = MTNL_myObjects[MTNL_myObjectCounter]; var MTNL_myOBject_currentLayer = MTNL_myObject.itemLayer; if (MTNL_myOBject_currentLayer != app.activeDocument.layers.firstItem() ) { var MTNL_myOBject_prevLayer = app.activeDocument.layers.previousItem(MTNL_myOBject_currentLayer); while (MTNL_myOBject_prevLayer.locked && MTNL_myOBject_prevLayer != app.activeDocument.layers.firstItem() ) { MTNL_myOBject_prevLayer = app.activeDocument.layers.previousItem(MTNL_myOBject_prevLayer); } if (!MTNL_myOBject_prevLayer.locked) MTNL_myObject.itemLayer = MTNL_myOBject_prevLayer; } } } } else { alert(MTNL_noSel); } //end of MoveToLayer Script