Skip to main content
deckarduk
Inspiring
December 5, 2022
Answered

InDesign scripting question re page numbers

  • December 5, 2022
  • 2 replies
  • 803 views

Hi everyone,

Please can someone helpo me...

I have a grep find set up in a script and all works fine.

Just wondered if it's possible to get the page number of each instance returned by the grep find?

Thanks in advance.

This topic has been closed for replies.
Correct answer brian_p_dts

Grep find typically returns a Text object. From there, you can get myFind.parentTextFrames[0].parentPage. Note that if the item is on the pasteboard, parentPage is null. Or if it extends across multiple text frames those frames might be on different pages. 

2 replies

m1b
Community Expert
Community Expert
December 5, 2022

For an example implementation of what @brian_p_dts described, see this post (search for "function textPage").

- Mark

deckarduk
deckardukAuthor
Inspiring
December 5, 2022

Hi Mark,

Thanks for the help, the linked discussion looks good 👍

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
December 5, 2022

Grep find typically returns a Text object. From there, you can get myFind.parentTextFrames[0].parentPage. Note that if the item is on the pasteboard, parentPage is null. Or if it extends across multiple text frames those frames might be on different pages. 

deckarduk
deckardukAuthor
Inspiring
December 5, 2022

Hi Brian,

Thanks for the help, I'll give that a go 👍