Skip to main content
Inspiring
October 22, 2018
Question

copy without constructor

  • October 22, 2018
  • 2 replies
  • 490 views

Hi experts

How to tell InDesign what I want to copy just the contents but not the constructor and formatting?

my script as below, but not working:

var

    mObject = app.selection[0],

    mTarget;

if (mObject.constructor.name == ("Cell") || mObject.constructor.name == ("Table")) {

    mTarget = mObject.cells.everyItem().paragraphs.everyItem().contents;

    }

if (mObject.hasOwnProperty ("paragraphs")) {

    mTarget = mObject.paragraphs.everyItem().contents;

    }

app.copy(mTarget);

Could someone tell me how to make it happen?

thanks

regard

John

This topic has been closed for replies.

2 replies

JohnwhiteAuthor
Inspiring
October 25, 2018

Hi Uwe

may get string from clipboard is a collect method for this script.

But I don't know how to write the code.

John

Community Expert
October 25, 2018

Hi John,

why do you mention the clipboard? To copy the contents of your selection is not necessary.

If you collected the contents to a variable you simply can assign the new contents to e.g. a selection point of some text to add it.

Or assign it as contents of a paragraph to change the contents of the paragraph.

Regards,
Uwe

Community Expert
October 22, 2018

Hi John,

what do you consider as the contents of a table?

If you want the contents of the whole table you'll get an array of contents simply with:

table.contents // array

Or you simply do:

app.selection[0].contents; // array of contents of selected cells or selected table

Regards,
Uwe

JohnwhiteAuthor
Inspiring
October 22, 2018

Hi Uwe

I consider it as some text without any formatting and constructor, something like copy from pdf.

my goal just copy the text from cells will paste to paragraph and no need to convert the cell to text.

thanks

John