Hi @A27300849wzxk ,
if you are working with two documents open, the active document is the one where you selected the items, the other one is the one you like to paste the selected items to, it could go like that:
// CopyPasteSelectedItemsToDifferentDoc-v1.jsx
// Copy selected items to the clipboard:
app.copy();
// Switch to the other document, the target document, if only two documents are open:
app.activeDocument = app.documents[1];
// Test if the spread of the target document is empty.
// Add a spread
// Make it the active one
var currentSpread = app.layoutWindows[0].activeSpread;
if( currentSpread.pageItems.length > 0 )
{
var nextSpread = app.activeDocument.spreads.add();
app.layoutWindows[0].activeSpread = nextSpread;
};
// Paste the contents of the clipboard to the active spread of the target document:
app.paste();
// To switch back to the source document:
app.activeDocument = app.documents[1];
That would work best if both documents are working with none-facing pages where every spread has only one single page and no elements are on the pasteboard. The script would add a new spread at the end of the target document when a selectable item is on the spread.
The code will get more complicated if you are using facing pages documents.
Instead of the line app.paste() one could also use app.pasteInPlace() if you want to maintain the relative position of the copied objects according to the source document.
Regards,
Uwe Laubender
( Adobe Community Expert )