Inspiring
March 31, 2023
Answered
Adding index entries via script
- March 31, 2023
- 2 replies
- 874 views
I use a simple script to add selected text to Index, however if I select two words and run this script the index marker won't be at the start of the selected text IF there are two multiple row tables before selected text in the story, but if I add the same selection to index via index panel it works as expected.
here is my code to add selected text to index, I also attached a file if anyone wants to try:
var selectedText = app.selection[0].contents;
var index = app.activeDocument.indexes[0];
var topic = index.topics.add(selectedText);
topic.pageReferences.add(app.selection[0].insertionPoints[0], PageReferenceType.CURRENT_PAGE);
