Skip to main content
June 22, 2012
Question

How do I get a page number for a story?

  • June 22, 2012
  • 1 reply
  • 3867 views

If I am looping through the stories in a document, and I want to know what page the story is on, how would I find that out?  This seems as if it would be the simplest thing in the world, but I have been up and down the object model for hours, and I am having no luck.

I must be missing something.  Can some kind soul here help me?

Thanks,

Thomas Ruschak

This topic has been closed for replies.

1 reply

Jongware
Community Expert
Community Expert
June 22, 2012

What version of InDesign? For any modern version, this ought to be enough:

alert (app.stories[0].textContainers[0].parentPage.name);

-- note that it will only report the first page of a story.

TRuschak1 wrote:

... what page the story is on ...

.. because a single story can run over many pages.

June 22, 2012

Sorry, my bad, I am on CS6.  I tried your suggestion in a js script alone.  When I ran it, I got this:

I usually do things in VBScript, just a bit more familiar with it.  However, if javascript is necessary, I am happy to use that.

Again, all I want is to be able to say what page a given story is on.  I'm happy to get the first page if it is on more than one.  I have spent the night being amazed at how hard that simple request is in InDesign.

Anyway, if you can, have pity on me and help some more

Tom

Jongware
Community Expert
Community Expert
June 22, 2012

My bad, 'stories' are not part of 'app'. Try

alert (app.activeDocument.stories[0].textContainers[0].parentPage.name);