Skip to main content
Known Participant
October 27, 2023
Question

Need a Support for a InDesign script for import bulk list items

  • October 27, 2023
  • 2 replies
  • 264 views

I whould like to develop a indesign script to import a batch of list items in combo box Items for interactive form. in indesign

 

Scope; instead of adding a list items manually one by one. i will create a Text list seprated with paragraph so that my script should import the text to combo box list items.

 

Please Help me to find the solution .

 

I got this from ChatGPT:
if (app.documents.length > 0) {
var doc = app.activeDocument;

if (app.selection.length == 2 && app.selection[0] instanceof TextFrame && app.selection[1] instanceof ComboBox) {
var textFrame = app.selection[0];
var comboBox = app.selection[1];

// Clear existing items in the combo box
comboBox.clear();

// Split the text in the text frame by paragraphs
var textItems = textFrame.texts[0].paragraphs;

for (var i = 0; i < textItems.length; i++) {
// Add each paragraph as an item in the combo box
comboBox.add(textItems[i].contents);
}
} else {
alert("Select one text frame and one combo box field.");
}
} else {
alert("Open a document first.");
}

 

 



Thanks in advance

This topic has been closed for replies.

2 replies

Colin Flashman
Community Expert
Community Expert
October 27, 2023

A similar question was asked earlier today too. I'll still recommend the combo mambo script that can be found on the CreativePro site: https://creativepro.com/combomambo-script-updated-indesign-cc-2014/

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!
GNDGN
Inspiring
October 27, 2023

This script should to the job:

var txtFile = File("/path/to/options.txt");
txtFile.open('r');
var options = txtFile.read().split("\n");

app.selection[0].choiceList = options;

Create a textfile with one option for every line and update the path to that file in the script above. Then select a combo box inside ID and run the script.

____________________Robotic Process Automation in Desktop Publishing (Book): https://doi.org/10.1007/978-3-658-39375-5