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

Link all text frames in document

Explorer ,
Mar 20, 2019 Mar 20, 2019

Copy link to clipboard

Copied

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!

TOPICS
Scripting

Views

2.4K

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 , May 11, 2022 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.

Votes

Translate

Translate
Advocate ,
Mar 25, 2019 Mar 25, 2019

Copy link to clipboard

Copied

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

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 ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

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!

 

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 Expert ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

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.

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 ,
May 12, 2022 May 12, 2022

Copy link to clipboard

Copied

That's just perfect, it helped me big time!

Thank you so so much,

EL

 

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 ,
Sep 02, 2022 Sep 02, 2022

Copy link to clipboard

Copied

Hello Peter, how do I modify the script for two text frames on each page? If there's more than one only every second frame is linked.

 

 

Bildschirmfoto 2022-09-02 um 12.59.36.jpg

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 ,
Sep 02, 2022 Sep 02, 2022

Copy link to clipboard

Copied

Never mind, Peter. I searched a little more and found this free script that does the job. https://www.rorohiko.com/wordpress/indesign-downloads/textstitch/

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
Explorer ,
Apr 03, 2024 Apr 03, 2024

Copy link to clipboard

Copied

Hi peter, 2 years later... is still there a way to make it work?

Thank You! 

 

צילום מסך 2024-04-03 ב-21.41.50.png

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 Expert ,
Apr 03, 2024 Apr 03, 2024

Copy link to clipboard

Copied

You'll have to provide some more detail. For example, do you have a single text frame on each page?

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
Explorer ,
Apr 03, 2024 Apr 03, 2024

Copy link to clipboard

Copied

Thank you!

 

Yes. 

צילום מסך 2024-04-03 ב-23.11.54.png

 

Ok now I see the issue...

It dos'nt work when there is some threads

(Every two frames are concatenated together, there are a lot of separated such pairs in the document, I need them all in one long thread.
When I left only 4 pages and disconnected them completely - only then the script works)

 

Is there a way to make the script work even when some frams are threaded?

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
Explorer ,
Apr 03, 2024 Apr 03, 2024

Copy link to clipboard

Copied

In other words:
Can a script go over the document and combine it into one thread?

 

Let's say I have ten chapters, and I broke threads in each chapter (using the 'BreakTextThread' script) to make the document faster, and now I want to connect everything back together.


Assuming there is one text frame per page, or mabe better - in a specific object style there is only one text frame in page

Is this possible using a script?

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 Expert ,
Apr 05, 2024 Apr 05, 2024

Copy link to clipboard

Copied

LATEST

Sure.  At the first line of the script enter the name of the object style.

ostyleName = 'Xyz';

sortedStories = [];
stories = app.documents[0].stories.everyItem().getElements();
for (i = 0; i < stories.length; i++) {
  if (stories[i].textContainers[0].appliedObjectStyle.name === ostyleName) {
    sortedStories.push (stories[i]);
  }
}

// An expensive sorter...
sortedStories.sort (function (a, b) {
  return a.textContainers[0].parentPage.documentOffset 
          - b.textContainers[0].parentPage.documentOffset;
});


for (i = sortedStories.length-1; i > 0; i--) {
  sortedStories[i-1].textContainers[0].endTextFrame.nextTextFrame = 
    sortedStories[i].textContainers[0];
}

 

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
New Here ,
Aug 28, 2023 Aug 28, 2023

Copy link to clipboard

Copied

hmmm this doesn't work anymore today. these are .js scripts right?

 

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
New Here ,
Aug 28, 2023 Aug 28, 2023

Copy link to clipboard

Copied

Screenshot 2023-08-28 at 14.59.20.png

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
Advocate ,
Mar 25, 2019 Mar 25, 2019

Copy link to clipboard

Copied

Otherwise only if you want to link two frames,

you can use this code.

firstTextFrame.nextTextFrame = secondTextFrame;

Best

Sunil

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