I’m having a big problem with an indexing script I wrote.
it searches for a certain character style and certain number formats.
the problem is that these numbers are being placed into cells which lie in one huge table which splits
itself over multiple pages. so the parent repeat doesn’t work, because I’ll always end up on page 1 with
the parent text frame.
i’m trying to get some other page reference by selecting the found text.
something like (it’s not true script, just to make clear, what I mean):
select myArticleNumber
return the name of the page of the selection
It’s been a while since I had to do this and it is a pain to discover. The problem as I recall is that between ID2 and ID CS they changed the way some properties into lists even if they contain a single entry, and this change was not well documented. What you want is to get the parent text frame of the text…it could be a character in the text flow or inside a table. The problem is that Adobe changed the parent text frame to a list so it is now parent text frames. To get the page number you need to get the name of the parent text frame of the selected text.
tell application "Adobe InDesign CS2"
set x to selection
set x to item 1 of x
set y to name of parent of item 1 of parent text frames of x
end tell
This should work for you if the text is selected. A routine that I did a while ago to help follows:
tell application "Adobe InDesign CS2"
set x to object reference of selection
tell document 1
set PageNo to ""
repeat while PageNo is ""
if class of parent of x is page then
set PageNo to name of parent of x
else if class of parent of x is story then
set x to item 1 of parent text frames of x
set PageNo to name of parent of x
else if class of x is cell then
set x to object reference of character 1 of contents of x
set PageNo to name of parent of item 1 of parent text frames of x
else
set x to object reference of parent of x
end if
end repeat
end tell
end tell
return PageNo