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

Can I Convert a Paragraph Style to a Script Label?

New Here ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

Hi all.

Is it possible to convert a Paragraph Style to a Script Label?

I have multiple boxes and so deleting or converting the style to text isn't an option.

I have the below but the Script Label reads "[object cell]'.

//This is only part of the script

//Place  canvas code

var myText = myTable.rows[6].cells[3];

var myParaStyle = myDocument.paragraphStyles.item("Lightbox Code");

myText.texts.item(0).applyParagraphStyle(myParaStyle, true);

myText.contents = "\r";

//Script label

var scriptLabel = myText.toString();

myCell.pageItems[0].label = scriptLabel;

TOPICS
Scripting

Views

582

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 ,
Feb 09, 2017 Feb 09, 2017

Copy link to clipboard

Copied

Hi

`myText` is not proper variable name, this is Cell Object.

var myText = myTable.rows[6].cells[3];

var scriptLabel = myText.toString();

I guess using `appliedParagraph.name` to Cell's Text solve your issue.

thank you

mg.

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
New Here ,
Feb 14, 2017 Feb 14, 2017

Copy link to clipboard

Copied

Hi MG.

Sorry but can you explain further?

I've tried the below code but get an error message -

//Script label

var scriptLabel = myTable.rows[6].cells[3].appliedParagraph.name;

myCell.pageItems[0].label = scriptLabel;

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 ,
Feb 14, 2017 Feb 14, 2017

Copy link to clipboard

Copied

LATEST

Hi sidd,

look up the DOM documentation and Help files of the ESTK.

Some valuable links in this thread here:

Re: indesign scripting tutorial

Object Cell has a texts property.
And object Texts has appliedParagraphStyle property. Not appliedParagraph.

And appliedParagraphStyle is indeed a PargaraphStyle, that has a name property.

And if the value of name is what you are after you can do it like that:

var scriptLabel = myTable.rows[0].cells[3].texts[0].appliedParagraphStyle.name;

because the value of name is a String object.

Labels can hold only Strings as value.

What exactly is behind variable myCell ?

And is a pageItem pasted in myCell?

Or is myCell a graphic cell and pageItems[0] is the container of an image that sits in the cell?

Note: You can also use the cell itself to label it.

myCell.label = scriptLabel;

And if you select the cell and the Script Label panel is open you will see the value of the label.

Example from my German InDesign CC 2017:

( Skriptetikett => Script Label , [Kein Absatzformat] => [No Paragraph Style] )

ScriptLabel-Cells-ShowingAppliedParagraphStyle-1.png

If you go through the cells using the arrow keys, the script label is changing, because I applied different paragraph styles and labeled all the cells:

ScriptLabel-Cells-ShowingAppliedParagraphStyle-2.png

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