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;
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.
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;
Copy link to clipboard
Copied
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] )
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:
Regards,
Uwe