Skip to main content
Participant
March 21, 2024
Answered

Need a Script to mark Text in InDesign

  • March 21, 2024
  • 3 replies
  • 607 views

Dear Community,

 

I am looking for a .js Script in InDesign that allows me search for a specific text. I haven't found a script yet that is working for me. I need this function for my text replacement project for further functions that allows me to replace the placeholder text in indesign with data from an excel-file.

 

At first, i only need the text finder function. In my example i have 5 textfields on my indesign page. In the first textfield is the text "product1", in the second "product2" and so on until "product5". Now i just need a script that finds these textphrases.

 

Thanks and kind regards

Luca

This topic has been closed for replies.
Correct answer Peter Kahrel

> At first, i only need the text finder function.

 

That's simple enough:

app.findTextPreferences = null;
app.findTextPreferences.findWhat = 'product1';
found = app.activeDocument.findText();

 This returns an array of found text objects.

3 replies

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
March 22, 2024

> At first, i only need the text finder function.

 

That's simple enough:

app.findTextPreferences = null;
app.findTextPreferences.findWhat = 'product1';
found = app.activeDocument.findText();

 This returns an array of found text objects.

Community Expert
March 21, 2024

Here is a script to try

Robert at ID-Tasker
Legend
March 21, 2024

Can't you use DataMerge?

 

LucaKnoopAuthor
Participant
March 21, 2024

Hey Robert,

 

no. Datamerge uses templates. But each side is individual. I want to produce a catalog and datamerch is not an option.

 

Thank you anyways! 🙂

Robert at ID-Tasker
Legend
March 21, 2024
quote

Hey Robert,

 

no. Datamerge uses templates. But each side is individual. I want to produce a catalog and datamerch is not an option.

 

Thank you anyways! 🙂


By @LucaKnoop

 

But technically speaking - your document is a template?

 

DataMerge is for producing Catalogues - unless your Catalogue is some special kind?

 

After script will find those 5x texts and update with the data - what next? What with the next record in your database?