InDesign CS2 - select words from a made list

tell application "Adobe InDesign CS2"
	tell document 1
			set TextWords to (words of text frames whose name of stroke color is "White")
		on error
			set TextWords to {}
		end try
			set TextWordsInGroups to (words of text frames of groups whose name of stroke color is "White")
		on error
			set TextWordsInGroups to {}
		end try
			set TextWordsInGroupsInGroups to (words of text frames of groups of groups whose name of stroke color is "White")
		on error
			set TextWordsInGroupsInGroups to {}
		end try
		set QtyOfAllTextWords to (count of TextWords) + (count of TextWordsInGroups) + (count of TextWordsInGroupsInGroups) as integer
		set AllTextWords to TextWords & TextWordsInGroups & TextWordsInGroupsInGroups

		repeat with i from 1 to QtyOfAllTextWords
			set selection to (item i of AllTextWords) -- <-- This bit doesn't work!!!
			delay 2
		end repeat

Why can’t I select the word?

Error returned: Adobe InDesign CS2 got an error: Invalid value for set property ‘selection’. Expected object, list of objects or nothing, but received “win”.

Help anyone!

try this line instead…
note that all I added was ‘object reference’

set TextWords to object reference of (words of text frames) whose name of stroke color is "White"

The problem you were having was that you were telling inDesign to select a string of characters as a literal.

What you need to do is tell it to select the reference to those words…ie: the actual object that is those words on the page.

for example - if you return TextWords in your script - you get something like…


but if you add the ‘object reference’ part you’ll get:
{text from character 1 to character 11 of text flow id 176 of document “Untitled-1”}

See how that makes a big difference…?

I still get tripped up by this sometimes too


This was doin my head in!!!

No I can move forward, rather than stale-mate.

Again, Thanks,