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?
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.
Save the document. Then place the cursor
...No worries, Les. This link will tell you all:
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:
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.
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.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
No worries, Les. This link will tell you all:
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
Copy link to clipboard
Copied
I was wondering if perhaps using a variable rahter than copy/paste might be another approach...
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.
Copy link to clipboard
Copied
Right. Forgot about the length and formatting limitiations.
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...
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.
Copy link to clipboard
Copied
> 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.