Thanks for these ideas William. williamc3112933 wrote Not that it's simple, but one way to get there is to climb up the parent tree checking for the constructor name until you find "Story". The problem is, you can go all the way up the tree and never see Story at all. If I select a cell and loop through consecutive parents (being careful to avoid an infinite loop, since the Application seems to think that it is its own parent!), I get this: Cell Table TextFrame Spread Document Application As you can see, TextFrame is the parent of Table, not Story. According to the docs, the parent of a Table could be Story, along with a dozen other possibilities, but in my testing it is not. That's another thing I don't understand about the parent–child relationship—it seems so random. Thankfully, someone at Adobe thought to give us a parentStory property for text. Why not for tables and cells too? Who knows. So anyway, at this stage I guess I need to loop through, check for Table, then use my old friend `storyOffset.parentStory` on the Table. I just thought there must be a more sensible way, but I'm slowly learning that Adobe's API is anything but sensible at times. williamc3112933 wrote Also perhaps helpful, below is a function I wrote to test if a selection is text or not. Here you can see the list of constructor names you might encounter. Perhaps not an answer to your question but hopefully guide you in the right direction. Ah yes, that looks very much like some code out of Adobe's JavaScript Scripting Guide (under 'Working with text selections') which I actually used myself in an earlier version of my script. I've since changed it to just: if (app.selection[0].hasOwnProperty("findGrep")) { … } Since the findGrep() method is what I actually want to call on the text, this is perfect for filtering out invalid sections, and satisfyingly concise. 🙂 (Unlike the code I'm going to have to write to find the parent story in all possible circumstances!)
... View more