Insertion point in Pages


I am trying to work out how I can set the insertion point in Pages based on a page number. The idea is to position the insertion point at the top of say page 2 of a three page document. Any ideas?

Thanks, Andy

I’ve worked it out, something along these lines…

tell application "Pages"
	set d to document 1
	repeat with pn from 1 to count of paragraphs of d
		set p to containing page of paragraph pn of d
		if page number of p = 2 then
			tell d to select insertion point before paragraph pn of d
		end if
	end repeat
end tell

Well done! I was completely stuck on that. This version also seems to work:

tell application "Pages"
	select insertion point before (first paragraph of front document whose containing page's page number is 2)
end tell