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

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

Community Beginner ,
Jan 18, 2024 Jan 18, 2024

Copy link to clipboard

Copied

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

Views

413

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 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

...

Votes

Translate

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/

Votes

Translate

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

Copy link to clipboard

Copied

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.

 

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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

 

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

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

Right. Forgot about the length and formatting limitiations.

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

Copy link to clipboard

Copied

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... 

 

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

Copy link to clipboard

Copied

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. 

 

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

Copy link to clipboard

Copied

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.

 

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