Here is a modified version of Martin’s macro, which will find all in the document. Note that it will also find across different text objects, which will allow it to find in the main document, as well as in table cells, and notes, etc.
# Find All In Index Topic
# This macro searches through all indexing topics in the document, ie: the "index as" text.
# It will select all marked text whose indexing contains the given search.
# Matching is case insensitive.
# Martin Wierschin 15-11-02
# Modified by P. Spaelti 15-11-05
$doc = Document.active
$indexName = Active Text Index Name
# ask user what to search for, defaulting to the last search value
$registry = Registry.applicationRegistry
$registryKey = "com.nisus.findIndexTopic.searchString"
$findWhat = $registry.loadValueWithName($registryKey)
$findWhat = Prompt Input "Search for what indexing topics?", "", "Search", $findWhat
$registry.saveValueWithName($findWhat, $registryKey)
$sels = Array.new
foreach $text in $doc.allTexts
$loc = 0
While $loc < $text.length
$attr = $text.attributesAtIndex($loc)
$range = $text.rangeOfAttributesAtIndex($loc)
$loc = $range.bound
$topicsArray = $attr.textIndexTopicsForStyleName($indexName)
If Defined $topicsArray
# check for match
$topicsStr = ""
ForEach $topics in $topicsArray
If 0 == $topics.count
# auto topic
$topicsStr &= $text.substringInRange($range)
Else
$topicsStr &= Cast to String $topics
End
$topicsStr &= "\n"
End
If $topicsStr.containsString($findWhat, 'i')
$sels.push TextSelection.new($text, $range)
End
End
End
End
if $sels.count
$doc.setSelection $sels
else
Prompt "No matching indexing topics found.", "Indexing for '$indexName' does not contain: $findWhat"
end
# end of macro #