Skip to main content
Inspiring
July 26, 2022
Answered

How to loop different textFrames having same name defined in layer?

  • July 26, 2022
  • 1 reply
  • 572 views

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";

          }

 

   }

This topic has been closed for replies.
Correct answer Manan Joshi

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

1 reply

Manan JoshiCommunity ExpertCorrect answer
Community Expert
July 26, 2022

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

-Manan
Inspiring
July 26, 2022

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'.

Inspiring
July 26, 2022