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

Scripting text frames connected in a flex layout (InDesign)

New Here ,
Nov 02, 2025 Nov 02, 2025

Hi,

since the flex layout is a brand new feature in InDesign, it is difficult for me to find anything about using scripts with it.

This page states that "flex layout is scriptable", however it links to InDesign ExtendScript API documentation, where I could not find even a mention of this flex layout (I believe it is just a question of few weeks).

Still - could any of you give me an advice, how to change content of a text frame, that is connected into a flex-layout object?

I have got my script working with simple (normal) text frames, now the flex-layout frames are ignored.

    var tfs = page.textFrames;
    var i = tfs.length;

    while(i--) {        
        if (tfs[i].contents == "search_string") {
            tfs[i].contents = "replace_string";
        }
   } 

 

Thank you very much for your hints.

Honza

TOPICS
Scripting
133
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 , Nov 02, 2025 Nov 02, 2025

Hi @Honza5CEF ,

consider a flex layout a special container object. Like a group for example.

So page.textFrames will not get text frames inside that container object.

 

What can you do?

Get all page items on the page and sort out the ones that are text frames.

 

// Get all page items on page:
var allPageItemsArray = page.allPageItems;
// Loop the array:
for( var n=0; n<allPageItemsArray.length; n++ )
{
	if
	( 
		allPageItemsArray[n].constructor.name == "TextFrame" && 
		allPageItemsArray[n].cont
...
Translate
Community Expert ,
Nov 02, 2025 Nov 02, 2025

Hi @Honza5CEF ,

consider a flex layout a special container object. Like a group for example.

So page.textFrames will not get text frames inside that container object.

 

What can you do?

Get all page items on the page and sort out the ones that are text frames.

 

// Get all page items on page:
var allPageItemsArray = page.allPageItems;
// Loop the array:
for( var n=0; n<allPageItemsArray.length; n++ )
{
	if
	( 
		allPageItemsArray[n].constructor.name == "TextFrame" && 
		allPageItemsArray[n].contents == "search_string" 
	)
	{
		allPageItemsArray[n].contents = "replace_string";
	}
};

 

Kind regards,
Uwe Laubender
( Adobe Community Expert )

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 Expert ,
Nov 02, 2025 Nov 02, 2025

Hi @Honza5CEF ,

what will you get by an alert that is asking for the parent of a selected object (e.g. a text frame) that is part of a flex layout?

// Object, eg. a text frame, inside a flex layout selected.
alert( app.selection[0].parent.constructor.name );

 

You could get all available properties and available values of the parent :

// Select an object inside a flex layout
// Get all property/value pairs of the parent of the selected object
// Write them to a new text frame of the same page

var page = app.selection[0].parentPage;
var parentOfSelection = app.selection[0].parent;

var resultFrame = page.textFrames.add( { geometricBounds : page.bounds } );
var propsContents = parentOfSelection.constructor.toString() +"\t"+ parentOfSelection.constructor.name +"\r" ;


var props = parentOfSelection.properties;

for( x in props )
{
	try{
	propsContents = propsContents + x +"\t"+ props[x].toString() +"\r" ;
	}catch(e)
	{
	propsContents = propsContents + x +"\t"+ e.message  +"\r";
	}
}
resultFrame.parentStory.contents = propsContents;

 

Kind regards,
Uwe Laubender
( Adobe Community Expert )

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
Mentor ,
Nov 02, 2025 Nov 02, 2025

I have manually searched thru an own object model view for "Flex".

 

Page items have a flexObjects collection and two related properties.

 

DirkBecker_0-1762097302263.png

 

There is a new page item derived class FlexObject:

 

DirkBecker_14-1762098465493.png

 

DirkBecker_2-1762097567034.png

DirkBecker_3-1762097633790.png

 

Some methods that suggest the implementor did not like InDesign concepts such as collections, LocationOptions etc.

 

DirkBecker_15-1762098712063.png

 

ObjectStyle has a new section that can get enabled

 

DirkBecker_4-1762097731147.png

DirkBecker_5-1762097770747.png

 

Here the attributes, should be the same as in page item

DirkBecker_6-1762097844531.png

 

Several related enums

 

DirkBecker_7-1762097988169.png

DirkBecker_8-1762098014314.png

DirkBecker_9-1762098047837.png

They should really have used AutoEnum instead of the latter, but yeah …

DirkBecker_10-1762098134378.png

DirkBecker_11-1762098161413.png

DirkBecker_12-1762098185093.png

DirkBecker_13-1762098215693.png

 

Almost missed this Application property (no matching Document property!):

also makes me wonder what they mean with "canvas"

 

DirkBecker_16-1762099163676.png

 

Document, Spread, Page also have a flexObjects collection

 

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
Mentor ,
Nov 02, 2025 Nov 02, 2025
LATEST

Sorry, should have made that a separate thread.

Anyway, for the text frames within flex it should be possible to descend from page.flexObjects collection, for each then use its allPageItems array as Uwe suggested, but there are also collections for textFrames, endnoteTextFrames and so forth. Of course everything could again be nested, also within groups or another level of flexObjects.

I haven't yet tried any script, just looking at the object model.

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