Skip to main content
Inspiring
October 18, 2023
Answered

Set Auto-Size on all text containers EXCEPT on frames with stroke color applied?

  • October 18, 2023
  • 2 replies
  • 599 views

Hi everyone,

I'm wondering if it's possible to adapt the script below, so that it works with all text containers EXCEPT on frames with stroke color "New Gradient Swatch" applied? Any help would be greatly appreciated! 🙂

for (var d=0; d<app.documents.length; d++)
{
var myDoc = app.documents[d];
var allTextContainers = [];

var allStories = app.documents[d].stories.everyItem().getElements();
var allStoriesLength = allStories.length;

for(var n=0;n<allStoriesLength;n++)
{
	allTextContainers = 
	allTextContainers.concat( allStories[n].textContainers );
};

var allTextContainersLength = allTextContainers.length;

for(var n=0;n<allTextContainersLength;n++)
{
	if( allTextContainers[n].constructor.name == "TextPath" )
	{ continue };

	allTextContainers[n].textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.TOP_CENTER_POINT;
   allTextContainers[n].textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_ONLY;
   
	allTextContainers[n].textFramePreferences.autoSizingType = 
	AutoSizingTypeEnum.OFF;
};
}
alert("Done!");


Thanks,
Rogerio

 

This topic has been closed for replies.
Correct answer Anantha Prabu G

Please add the following after {continue}

 

if(allTextContainers[n].appliedObjectStyle.name ==("Numbers"))

{ continue };

 

Thanks,

Prabu G

2 replies

Anantha Prabu G
Anantha Prabu GCorrect answer
Legend
October 19, 2023

Please add the following after {continue}

 

if(allTextContainers[n].appliedObjectStyle.name ==("Numbers"))

{ continue };

 

Thanks,

Prabu G

Design smarter, faster, and bolder with InDesign scripting.
Inspiring
October 19, 2023

It worked! Thank you so much! 🙂

Anantha Prabu G
Legend
October 19, 2023

Thank You @Rogerio5C09 

Design smarter, faster, and bolder with InDesign scripting.
Inspiring
October 18, 2023

If it helps, I created an object style "Numbers" and applied to all the stroke text frames.

Inspiring
October 18, 2023

@Laubender I copied over your script from an old post. Maybe you can help me to adapt this one as per my request above? Thx! 🙂