• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

copy without constructor

Contributor ,
Oct 21, 2018 Oct 21, 2018

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

TOPICS
Scripting

Views

322

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 22, 2018 Oct 22, 2018

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 22, 2018 Oct 22, 2018

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 25, 2018 Oct 25, 2018

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 25, 2018 Oct 25, 2018

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines