How to get page count of multiple styles into one page count field?

I have a document with with two sections:

  • body
  • appendixes

There are several appendixes and each of them have their own page style (appendix1, appendix2 etc.).

I want to have a field which gives me the total page count of all the appendix pages combined so I can write something like this: “This document has 327 pages of which XX are appendixes”. I tryed using bookmarks and cross-references like in this thread (Separate page count for each style?) without success.

Can you help?

Insert an own page count variable at begin of the appendix. You find it in Insert > Fields > Others > Variables > Set Page variable. Then insert as last character in the appendix text (not in the footer) the variable “Show Page Variable”. Define this field as reference as was described in the mentioned thread. You can set the character style to ‘hidden’. When you need this value, then insert a reference to it of type ‘reference’.

If you add or remove text, you have to manually update the field via Tools > Update.

A page variable counts from its start, independent of page styles and shows the number of pages from its start on. There is only one such custom page variable.