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

Script for copying text from one text box into five other text boxes

Community Beginner ,
Jan 18, 2024 Jan 18, 2024

Hi

I need a script which allows me to write some text in a text box, and then it automatically copies the same text into five other text boxes when the script is run.

I wondered if each text box has an “object name” or an “object number” or some other identifier which might help with the script – but I cannot find any way to do this.

My InDesign scripting skills are at the novice stage and I don't know how to do this - or if it is even possible to do. Can anyone help please?

TOPICS
Scripting
536
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

Community Expert , Jan 18, 2024 Jan 18, 2024

Well, using the content collector/placer you'll have to do a lot of clicking, which is made more awkward if the frames aren't on the same spread.

 

A simple script is much more convenient, especially if you assign a keyboard shortcut to it.

 

First, label the text frames on the Layers panel. I used one, two, three, etc. To label a frame, select it, then do a slow double-click on its name in the panel. Unlabelled frames have some text in angle brackets.

PeterKahrel_0-1705575548841.png

 

Save the document. Then place the cursor

...
Translate
Community Expert , Jan 18, 2024 Jan 18, 2024

No worries, Les. This link will tell you all:

 

https://creativepro.com/how-to-install-scripts-in-indesign/

Translate
Community Expert ,
Jan 18, 2024 Jan 18, 2024

Why do you need a script if a native function of InDesign is doing that?

Use the the contents tools:

  • Content Collector Tool
  • Content Placer Tool
  • Convoyer Panel with the available options.

 

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 ,
Jan 18, 2024 Jan 18, 2024

Well, using the content collector/placer you'll have to do a lot of clicking, which is made more awkward if the frames aren't on the same spread.

 

A simple script is much more convenient, especially if you assign a keyboard shortcut to it.

 

First, label the text frames on the Layers panel. I used one, two, three, etc. To label a frame, select it, then do a slow double-click on its name in the panel. Unlabelled frames have some text in angle brackets.

PeterKahrel_0-1705575548841.png

 

Save the document. Then place the cursor in the frame whose content you want to duplicate to the labelled frames and run this script:

names = ['one', 'two', 'three', 'four', 'five'];
text = app.selection[0].parentStory;
for (i = 0; i < names.length; i++) {
  text.duplicate (
    LocationOptions.AT_BEGINNING, 
    app.activeDocument.textFrames.item (names[i])
  );
}

 

Naturally, you'll need to replace the labels one, two, etc. with the your labels.

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 Beginner ,
Jan 18, 2024 Jan 18, 2024
Thanks a lot for this, Peter,
I am an absolute beginner with using (let alone writing!) scripts - but it look like this script should do what I want. I have already named the text boxes in preparation for running the script.
My problem is that as a complete novice to scripting I'm not sure how to run it. I am aware that if it had a name and the .jsx suffix I can add it to my scripts panel and run it from there - but I need to know how I can name this script and give it the .jsx suffix first.
I'm sorry this is such a basic question, but I'm a very basic beginner!
Many regards,
Les King
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 ,
Jan 18, 2024 Jan 18, 2024

No worries, Les. This link will tell you all:

 

https://creativepro.com/how-to-install-scripts-in-indesign/

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 Beginner ,
Jan 18, 2024 Jan 18, 2024

Thanks, Peter,

As it happens I subscribe to Creative Pro - it's very useful, although I obviously missed this, so thanks for passing on the link!

Many regards, Les King

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 ,
Jan 18, 2024 Jan 18, 2024

I was wondering if perhaps using a variable rahter than copy/paste might be another approach...

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 ,
Jan 18, 2024 Jan 18, 2024

I hadn't even thought about that. It'll work if the text contains no formatting and fits on one line of text.

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 ,
Jan 18, 2024 Jan 18, 2024

Right. Forgot about the length and formatting limitiations.

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 ,
Jan 18, 2024 Jan 18, 2024

Script could also work on the order of selected TFs - 1st one is "source" - the rest are "destinations" - that way, the minimum of selected objects would be two - without the limit on destination - as long as they are on the same spread and its Pasteboard. 

 

If you would like to go even further - different spreads - and even documents - been there, done that... 

 

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 ,
Jan 18, 2024 Jan 18, 2024

Or, script could search for non-empty TF - use it as "source" - and populate the rest. 

 

Possibilities are endless... 

 

Including a situation, when you select a TF, it will be automatically treated as "source", then next selected TFs will be automatically populated. Till you "reset" the process. 

 

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 ,
Jan 18, 2024 Jan 18, 2024
LATEST

Script could also work on the order of selected TFs

> Or, script could search for non-empty TF 

 

The script could work in many ways.

 

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