Copy link to clipboard
Copied
Variable Page Count has it's quirks:
The core to get the desired information for summing up the total is quite simple:
KLD_Z.GetPageNums = function (oDoc) {
/* Get information about page numbers
Arguments oDoc document to be handled
Returns object with the following properties:
.nFirst Page number of first body page (integer)
.nPages Number of body pages
.iFormat Format of pagen number (an integer!)
*/
var oPage, obj= {};
obj.nFirst = oDoc.FirstPageNum;
oPage = oDoc.LastBodyPageInDoc;
obj.nPages = oPage.PageNum + 1;
obj.iFormat = oDoc.PageNumStyle; // is an integer
return obj;
} //--- end GetPageNums --------------------------------------------------------------------
... but the whole task GetBookPageCount to define/insert/update a user variable BookPageCount in all (*.fm) book files requires some ancillary functions: CollectDocsInBook, DefineUserVariable, GetSimpleOpenProps, GetText, GetVariableValue, Message, OpenDocOrBook
I have put this together into a ZIP. Place both the contained file and the subdirectory in the StartUp folder. To use the function, have a book active, open the Script Library, check "Autorun" to list the scripts of the StartUp folder; select GetBookPageCount.jsc and use the Run button.
The relevant files are opened and get the variable, which then can be used... In the next run with the same book the variable is updated.
Well, the resulting script may be viewed as elaborate - You are free to cut it down to a 'one-liner'...
The attached file can not be ZIP, hence you need to rename from txt to zip after download! Heck, the txt was not accepted - I try with jpg. Aaaargh! Even this is not accepted as an attachement! → https://www.daube.ch/docu/files/GetBookPageCount.zip
Have something to add?