Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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