How to count pages in a Write Pro document?


How do you get the number of pages there is in a Write Pro
document by code. I’ve been looking for a property “wk page count”
or something similar, but can’t find anything useful.
With 4D write you could do: WR Count ($area;wr nb pages)

Best Regards
Magnus Torell

you can try something like that:

// Footer
$footer:=WP New footer($section)
// #TODO: ST Insert Expression -> wp insert formula v18R2
// WP INSERT FORMULA($footer;formula(this.pageNumber);wk append)
ST INSERT EXPRESSION($footer;"$wp_pageNumber";ST End text)
WP SET TEXT($footer;" / ";wk append;wk include in range)
// WP INSERT FORMULA($footer;formula(this.pageCound);wk append)
ST INSERT EXPRESSION($footer;"$wp_pageCount";ST End text)


1 Like

Hello Armin,

Thanks… Soo blind :slight_smile:


Starting with v18R2 you can also use WP Insert formula rather that ST Set expression.

This command is described here

In this case (v18r2), the formula could be << This.pageNumber >> (as a formula, not a string!

Managing formulas


Roland Lannuzel

If you looked my code, you get ST INSERT EXPRESSION format and the new WP INSERT FORMULA (as comment) just below each instructions :wink: