Copy link to clipboard
Copied
I am new to Indesign scripting. I have an simple task, which needs your help.
Task: I want to move all the text frames which contains a particular swatches applied to the content. I had wirtten the below script, but it's not working. The execution get finished without errors, but the result in nothing happened.
var mydoc=app.documents.item(0);
var mytexts=mydoc.stories.everyItem().paragraphs.everyItem().getElements();
for (i=0;i<mytexts.length;i++) {
var mytext=mytexts;
if (mytext.contents.fillColor=="swatches"){
mytext.parentTextFrames.everyItem().itemLayer=mydoc.layers.item("test");
}
}
Hope you experts will rectify this.
Thanks much in advance
Copy link to clipboard
Copied
Hi,
you've gone to far 😉 'content' is always the end of the road ... the pargraph itsself has got the property fillColor
...
if (mytext.fillColor.name == "mySwatchName"){...
But, what if the paragraph has more then one fillColor¿ You'll only get the first in use.
If important for your work -> think about doing a search.
Hans-Gerd Claßen
Copy link to clipboard
Copied
hi sundar,
i tried,,
var mydoc=app.documents.item(0);
var mytexts=mydoc.stories.everyItem().paragraphs.everyItem().getElements( );
for (i=0;i<mytexts.length;i++) {
var mytext=mytexts;
if (mytext.fillColor.name == "blue") {
mytext.parentTextFrames.everyItem().itemLayer=mydoc.layers.item("blue layer");
}
}
but the error message is. mytext.parentTextFrames.everyItem is not a function. highlighting the above boldened text. can you help on this
Copy link to clipboard
Copied
Yes you're right!.