I have a macro that creates a document from a template file with a small page size (for a label), filling out fields with info from a query, and sometimes, the strings in the fields are long enough to make the contents spill over onto a second page. In order to have it make adjustments to keep it on one page, I need the macro to find how many pages the document has. If, for example, I have an object oDoc that is the label document, how could I go about having the macro find out how many pages it has?
Not versed in macros, but if you only need this information visually, the number of pages is shown in the bottom status bar (as “Page x of y” if you’re currently on page x).
If your document has “margins”, you can also display the page count in some header or footer located inside the top or bottom margins (adjustments to be made in the page style). Just
As a fool-proof measure, make this field hidden so that it doesn’t print in any circumstances and tune LO to display hidden text.
pagecount = oDoc.CurrentController.PageCount