Skip to main content
Participating Frequently
February 10, 2016
Answered

copy content to another document certain layer

  • February 10, 2016
  • 1 reply
  • 928 views

Hello people I have made following code,

its a batch script

I want to copy all content from a document to another.

My issue is to activate a certain layer

Could someone help me?

see code here

[code]

//textLayer= app.activeDocument.layers.add ({name: "TT_IDML"});

var docSource=app.activeDocument;

var myFolder = Folder.selectDialog("Choose the folder")

if(myFolder.length==0)

{

    alert("No Folder Selected")

    exit(0)

    }

var myFiles = myFolder.getFiles("*.idml")

if(myFiles.length==0)

{

    alert("No InDesign files in folder")

    }

for(i=0; i<myFiles.length; i++)

{

 

    myFile = myFiles

//    alert(myFile)  

    app.open(myFile)

var docTarget=app.activeDocument;

var paletteObjects = app.activeDocument.layers[0].allPageItems;

app.select(paletteObjects);

app.copy();

app.activeDocument=docSource;

app.documents[0].layers.itemByName("TT_IDML").select;

    // app.pasteInPlace()

  

    }

[/code]

thank you in advance

This topic has been closed for replies.
Correct answer Laubender

There is no pasteInPlace() method on the Layer Object; only an

app.pasteInPlace();

No extras to it.

If you want the active layer, you first have to make a layer the active one.

app.documents[0].activeLayer = app.documents[0].layers.itemByName("TT_IDML");

app.select(null); // Be careful what is selected, if you are using pasteInPlace()

app.pasteInPlace();

or maybe only:

app.documents[0].activeLayer = "TT_IDML";

app.select(null);

app.pasteInPlace();

Not tested, but should work.

Please report back…

There are other methods to duplicate page items from one document to another.

See the duplicate() method of the PageItem Class.

Adobe InDesign CS6 (8.0) Object Model JS: PageItem

Uwe


There are also controls, if the original layers should be used, if something is pasted in.

See the InDesign preferences.

app.clipboardPreferences.pasteRemembersLayers = false; //or true, set this as you need it.

See also:

Adobe InDesign CS6 (8.0) Object Model JS: ClipboardPreference

Download the DOM documentation here:

Indesign JavaScript Help

Or search here for more recent versions:

InDesign ExtendScript API (10.0)

InDesign ExtendScript API (11.0)

Uwe

1 reply

Community Expert
February 10, 2016

The admins should move this thread to the InDesign Scripting Forum:

InDesign Scripting

In the meanwhile:

Hi Elmnas,

why do you add a new layer in your source document?

Uwe

Peter Spier
Community Expert
Community Expert
February 10, 2016

Uwe,

You type faster than I can move things...