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

How to auto-update a text frame with the first word of the next threaded frame

Contributor ,
Sep 07, 2025 Sep 07, 2025

Didn't Helen Keller say: "Do not tell me it cannot be done!"

With the help of AI I created a script to get the *first word* of the text frame in a thread *that comes after the currently selected text frame and insert that word into a third text frame.

Works great.

But sometimes the contents of the story change, and in turn, that first word of the next frame in the thread. Is there a way to cause the text in the third text frame to be updated dynamically so I don't have to keep deleting that frame and running the script again and again?

So what we want here is some type of expression like: MyText = (first word of text frame XYZ) (from my Pascal days) inside the properties of text frame 3. I don't know what the heck i am talking about....:(

Any ideas?

SF

 

<Title renamed by MOD>

TOPICS
How to , Scripting , Type
1.2K
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 2 Correct answers

Contributor , Sep 07, 2025 Sep 07, 2025

Thank you again for your help.

I am including the script file. As I said, it "does its thing" perfectly. Deleting all the text frames that have the object style applied i can also handle with the help of AI. But all the AI choked on doing the thing for the entire doc. I have included a demo doc as well that has two text frames with overflow and the object style referenced by the script. (Change the extension of the script to js)

This whole thing for using in Hebrew....(should not have any effect o

...
Translate
Contributor , Sep 07, 2025 Sep 07, 2025

Hi Good morning!

I was able to get AI to do all the textframes in the story. But I still have one small issue, which i was hoping you could help me with (and as I said, i want to pay if necessary)

The text frame that the script inserts should be positioned just below the text frame (we'll call this frame1) that has the overflow. Its left border should align exactly with the left border of frame1, and its top border should be 1 point below the bottom border of frame1

I am including the updated scrip

...
Translate
Community Expert ,
Sep 07, 2025 Sep 07, 2025

I don't think it is possible to have this done dynamically to auto update the frame whenever the text in the thread reflows. Any workflow would need to retrigger some script

-Manan

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
Contributor ,
Sep 07, 2025 Sep 07, 2025

Can we re-trigger the script when the text is updated?

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
Engaged ,
Sep 07, 2025 Sep 07, 2025

"Do not tell me it cannot be done!" ^^

 

It could. I suspect this would create a new textframe and add content rather than updating the existing one though.
Without seeing the actual code, we cannot provide much help.

 

What you could try is :

- Checks if there is a script label applied to the selected textframe

- If there is none, the current functions are used.

- Then add a script label to the selected textframe

- If there is a ScriptLabel (meaning you've already run the script on the selected textframe) the script does something else, ie erasing the first word of the following textframe and replacing it by the new one

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
Engaged ,
Sep 07, 2025 Sep 07, 2025

"Do not tell me it cannot be done!"

That's totally true.

"Simply done"  may however be a wrong thing to say.

 

I agree with what Manan Joshi said.

"Dynamically" usually means low level coding, meaning plugins, meaning not "simple".

I see scripts as "special actions", not too much "persistant actions". This is not entirely true of course, but when it comes to text formatting, it is usually the case.

That being said, 
- If I'm not mistaken, you are using the script after selecting one textframe. You do that multiple times on different TextFrames.

- If the content evolves, you need to identify the right TextFrames and run the very same script on them specifically.

 

What may be interesting to do is :

- Making a script that updates all the right textframes at once. There may me a pattern in the way your stories are made that can help. If not, there is something called "Script label", basically a tag that can be applied to a textframe and be used within a script to identify the target. When running the original script the first time, you could tag the selected textFrames with a Script Label. then, if content has evolved anywhere, you can run a new script that does exactly the same thing than the original one, but instead of targetting the selected textFrame, you target all the textframes that have the Script Label.

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
Contributor ,
Sep 07, 2025 Sep 07, 2025

Thank you for your attention and reply!

Please forgive my mental slowness. It is one of these days...

I **would prefer** the following (here I am giving details of actually what I need the script for):

I run the script once, and it does "its thing" to ALL text frames that have text overflow. I.e. It creates a little text frame below the frame with the overflow and inserts the first word of the next frame in the thread into that little frame (which is defined with an object style)

Then, say, I go and edit here and there, and the story changes. 

We (albeit manually) re-run the script again. It clears the content of all those little frames (or just deletes them) and does its thing again on the new version of the story.

My problem is, as I said, that this script was created by AI to work **on one frame, the selected one**. So right now I go through the entire doc and manually select/run the script again and again on each frame. I tried to get AI to do it for all the frames that overflow in the doc and it couldn't cut it. So I gave up 😞

Could I upload the script (which works perfectly for one selected frame) and maybe you (or some other genius) could add the above-mentioned functionality (entire doc, repeating and fixing after edits) ?

I would be happy to "buy some coffee" if someone would volunteer.

Thank you

 

SF

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
Engaged ,
Sep 07, 2025 Sep 07, 2025

Thanks for the extra information. Having some context does help.

 

From what I understand, there are 2 things that could be done:

- The script seems to work from a selected text frame, that actually identifies the story and possible text overflow. Creating a loop on all the stories of the active document should solve the issue of doing it manually.

- Since you applied an object style to the extra Text Frame, just making a loop that erases all the text frames using that particular Object Style, at the beginning of the script, should solve that aspect as well.

 

If your current script works fine, I recommend providing it as well as an ID file (with placeholder text for instance)  that would serve as a guinea pig ^^ What's important for people to see here is the structure, not the content.

It would be more helpful for people, and see how to help in a more accurate way. 

 

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
Contributor ,
Sep 07, 2025 Sep 07, 2025

Thank you again for your help.

I am including the script file. As I said, it "does its thing" perfectly. Deleting all the text frames that have the object style applied i can also handle with the help of AI. But all the AI choked on doing the thing for the entire doc. I have included a demo doc as well that has two text frames with overflow and the object style referenced by the script. (Change the extension of the script to js)

This whole thing for using in Hebrew....(should not have any effect on anything)

Thank You so, so much!

("Milat Hemshech" means in Hebrew "Word continuation")

 

 

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
Contributor ,
Sep 07, 2025 Sep 07, 2025

Hi Good morning!

I was able to get AI to do all the textframes in the story. But I still have one small issue, which i was hoping you could help me with (and as I said, i want to pay if necessary)

The text frame that the script inserts should be positioned just below the text frame (we'll call this frame1) that has the overflow. Its left border should align exactly with the left border of frame1, and its top border should be 1 point below the bottom border of frame1

I am including the updated script (you will need to change the script extension to ".js" ) as well as the demo doc.

 

Thank You!

SF

 

Edit/Update:

Eventually, I was successful in getting this done using the add-on "Mate" (it apparently is not bent on one AI engine but tries the best per the desired task), and it works fine.

The Mate add-on is definitely worth the 4$ a month price!!

I appreciate all the good will of everybody here!

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
Engaged ,
Sep 08, 2025 Sep 08, 2025

hey @SuzzyFlamingo 

seems like it's working here
I'm not much familiar with Right To Left implication, technically speaking for Indesign. I suspect there are quite a few tweaks that must be done, on some cases. Maybe not there. You'll see
Give it a try and see how it goes. You should anyway be able to start from there and add some more alert boxes if they are really needed

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
Contributor ,
Sep 08, 2025 Sep 08, 2025
LATEST

Yes works fine. Thank you. Now all i need is real-time updating....

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 ,
Sep 07, 2025 Sep 07, 2025

There's "afterAttributeChanged" event trigger (as well as several other "after" triggers). I don't know if any of them can be employed to achieve what you need.

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
Contributor ,
Sep 07, 2025 Sep 07, 2025

I absolutely have no idea about this. But it would seem that if it can be done once, it can loop through them all....

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