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

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

Engaged ,
Jul 26, 2022 Jul 26, 2022

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

          }

 

   }

TOPICS
Scripting

Views

208

Translate

Translate

Report

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

Votes

Translate

Translate
Community Expert ,
Jul 26, 2022 Jul 26, 2022

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

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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;

 

Votes

Translate

Translate

Report

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