Skip to main content
diogoferreira
Inspiring
March 20, 2019
Answered

Link all text frames in document

  • March 20, 2019
  • 2 replies
  • 4937 views

Hi everyone!

Anyone knows how to link all the text frames (Thread) in document and what is the best way to do that?

Can I create the text frames on master spread and then link all of the the in the document? Or should I create the directly on the document pages?

And before that, how can I link all of them?

Thanks in advance!

This topic has been closed for replies.
Correct answer Peter Kahrel

There are a few problems with Sunil's script. The error you got was caused by the fact that allPages is a collection, and collections don't have the textFrame property.

If the conditions are the same as Sunil assumed (a single text frame on each page), you can use this code:

pages = app.documents[0].pages.everyItem().getElements();
thread = pages[0].textFrames[0];
for (i = 1; i < pages.length; i++) {
  thread.endTextFrame.nextTextFrame = pages[i].textFrames[0];
}

 P.

2 replies

Sunil Yadav
Legend
March 25, 2019

Otherwise only if you want to link two frames,

you can use this code.

firstTextFrame.nextTextFrame = secondTextFrame;

Best

Sunil

Sunil Yadav
Legend
March 25, 2019

Hello diogo,

 

If your document has multiple pages and each pages has only single text frame of size of type area.

Assuming this, you can use this below code to link these textFrames as follows:

 

//// Assuming Every Page has only one main textFrame ---

var myDoc = app.documents[0];

var allPages = myDoc.pages;

var currentFrame = allPages[0].textFrames[0];

for(var i = 1; i < allPages.length; i++){

    currentFrame.nextTextFrame = allPages.textFrames[i];

    currentFrame = allPages.textFrames[i];

    }

 

Best

Sunil

Participating Frequently
May 11, 2022

Hi,

this would save my life.
I'm on the latest Indesign version and unfortunately I'm getting this error: "object does not support the property or method 'textFrames'" on string 6  'currentFrame.nextTextFrame = allPages.textFrames[i];'

 

Please help!

 

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
May 11, 2022

There are a few problems with Sunil's script. The error you got was caused by the fact that allPages is a collection, and collections don't have the textFrame property.

If the conditions are the same as Sunil assumed (a single text frame on each page), you can use this code:

pages = app.documents[0].pages.everyItem().getElements();
thread = pages[0].textFrames[0];
for (i = 1; i < pages.length; i++) {
  thread.endTextFrame.nextTextFrame = pages[i].textFrames[0];
}

 P.