Pages: Get page number of paragraph

Hi my dear gurus,
I have a good question for you. I am trying to script iWork Pages 2, but, as you know, the documentation provided by Apple is zero.

The routine I am building is to search for a particular type of paragraph and prints its page number. Simple? not so fast.


tell application "Pages"
	set NameText to "xxx.pages"
	
	repeat with z from 1 to the count of paragraphs of body text of document NameText
		if (paragraph style of paragraph z of body text of document NameText is "Title") then
			set PageNumber to page number of (paragraph z of body text of document NameText)
			display dialog PageNumber
		end if
	end repeat
end tell

Then I get the following error message:

This error highlights the following line:

set PageNumber to page number of (paragraph z of body text of document NameText)

How can I read the page number property of a document? Nothing seems to work! Please help, I am desperate.

Thanks.

Looking in the dictionary, I see that paragraphs don’t contain a page number property. That is the reason you’re getting an error. (Page number is a property of the page class, which is contained by the document or section class.)

We’re talking about documents know?

So? Will you left me in this suspense? :rolleyes:

Suppose I want to do a program to search for the occurrence of the word “beach” and make a list of all page numbers where this word appears. Will it be impossible to do in Pages?

I believe so.

I cannot believe! :confused:

let me ask a different way… for God’s sake, how to use that PAGE NUMBER property of Pages dictionary?
Isn’t that property there so one can get the current page number?
how to use that?
please give me an example.
thanks