Copy link to clipboard
Copied
I have a few textboxes in a doc and want to set the content to "xx". But below script not working.
var myDoc = app.activeDocument;
var i;
var myFrames = myDoc.allPageItems;
for (i=0; i < myFrames.length; i++)
{
if(myFrames.itemByName == "Idea")
{
myFrames[i].content = "xx";
}
}
1 Correct answer
Try the following
var myDoc = app.activeDocument;
var i;
var myFrames = myDoc.allPageItems;
for (i=0; i < myFrames.length; i++){
if(myFrames.name == "Idea")
{
myFrames[i].content = "xx";
}
}
-Manan
Copy link to clipboard
Copied
Try the following
var myDoc = app.activeDocument;
var i;
var myFrames = myDoc.allPageItems;
for (i=0; i < myFrames.length; i++){
if(myFrames.name == "Idea")
{
myFrames[i].content = "xx";
}
}
-Manan
Copy link to clipboard
Copied
Hi Manan, thanks for the reply.
This works => myFrames.name == "Idea" but while running the script I receive error in follwoing line:
myFrames[i].content = "xx"; // Object does not support the property or method 'content'.
Copy link to clipboard
Copied
use "contents"
The below link can help you
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PageItem.html#d1e208274
Copy link to clipboard
Copied
oh yes, thank you. Thanks for noticing this typo.
now i have adjusted the script to loop only in textFrames. Maybe it save a fraction of second 🙂
var myFrames = myDoc.textFrames;

