It only applies to situations outside the left page.
Hi @dublove , If you can’t get @m1b code to work try this—it gets the selection’s parent which is a spread and is not null. Note that a spread could have up to 10 pages, so this moves the object to the spread’s closest outside page:
var d = app.activeDocument;
//set the document’s ruler origin to spread and zero point to 0
d.viewPreferences.rulerOrigin = RulerOrigin.SPREAD_ORIGIN;
d.zeroPoint = [0, 0];
//The first item in the selection
var sel = d.selection[0];
//make sure there is a selection that has bounds
if (sel == undefined || !sel.hasOwnProperty("geometricBounds")) {
alert("No Text Frame Selected")
} else {
//if the selection is not on a page move it
if (sel.parentPage == null ) {
var mp = movePBSel(sel)
alert("Moved to page: " + mp.name)
}
}
/**
* Move a pasteboard selection
* @ param the selection to move
* @ return the parent page after the move
*/
function movePBSel(s){
//the selection’s parent is a spread even if it is off the page
var pp = s.parent.pages
//move to the nearest page’s top, left margin
if (pp.length == 1) {
s.move([ pp[0].marginPreferences.left, pp[0].marginPreferences.top ] );
} else {
//a selection on the pasteboard to the left or right of the spread
if (s.geometricBounds[3] < 0) {
s.move([pp[0].marginPreferences.left, pp[0].marginPreferences.top ]);
} else {
var px = pp[pp.length-1].bounds[1]
s.move([ px+pp[0].marginPreferences.left , pp[0].marginPreferences.top ] );
}
}
return s.parentPage
}
Selection on the pasteboard to the left of a sprread:
Selection on the pasteboard to the right of a sprread:
... View more