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

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

Engaged ,
Jul 26, 2022 Jul 26, 2022

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

          }

 

   }

TOPICS
Scripting
365
Translate
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

correct answers 1 Correct answer

Community Expert , Jul 26, 2022 Jul 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

Translate
Community Expert ,
Jul 26, 2022 Jul 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

Translate
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
Engaged ,
Jul 26, 2022 Jul 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'.

Translate
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 Beginner ,
Jul 26, 2022 Jul 26, 2022
Translate
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
Engaged ,
Jul 26, 2022 Jul 26, 2022
LATEST

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;

 

Translate
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