page number header How can I add the current page number and total page number to the header? /* AddPageNumbering.rex */ /* Macro */ /* get the script context, the XModel and the XTextDocument interface */ xScriptContext=uno.getScriptContext() oDoc=xScriptContext~getDocument xTextDoc=oDoc~{%see com.sun.star.text.XTextDocument%XTextDocument} /* access the PageStyles using XMultiServiceFactory */ xServiceManager=oDoc~{%see com.sun.star.lang.XMultiServiceFactory%XMultiServiceFactory} xPageStyle=xServiceManager~createInstance("{%see com.sun.star.style.PageStyle}") xFamiliesSupplier = xTextDoc~{%see com.sun.star.style.XStyleFamiliesSupplier%XStyleFamiliesSupplier} xStyle=xFamiliesSupplier~getStyleFamilies~getByName("PageStyles")~{%see com.sun.star.container.XNameContainer%XNameContainer} /* set the Header up */ xHeader=xStyle~getByName("Standard") HeaderProperty=xHeader~{%see com.sun.star.beans.XPropertySet%XPropertySet} HeaderProperty~setPropertyValue("HeaderIsOn", box("boolean", .true)) headerText=HeaderProperty~getPropertyValue("HeaderText")~{%see com.sun.star.text.XText%XText} /* Creating the total number of pages */ pageCount=xServiceManager~createInstance("{%see com.sun.star.text.TextField.PageCount}") pageCountTC=pageCount~{%see com.sun.star.text.XTextContent%XTextContent}() pageCountPS=pageCount~{%see com.sun.star.beans.XPropertySet%XPropertySet}() pageCountPS~setPropertyValue("NumberingType", box("Short", bsf.getConstant("{%see com.sun.star.style.NumberingType}", "ARABIC"))) /* Creating the actual page number */ pageNumber=xServiceManager~createInstance("{%see com.sun.star.text.TextField.PageNumber}") pageNumberTC=pageNumber~{%see com.sun.star.text.XTextContent%XTextContent}() pageNumberPS=pageNumber~{%see com.sun.star.beans.XPropertySet%XPropertySet}() pageNumberPS~setPropertyValue("NumberingType", box("Short", bsf.getConstant("{%see com.sun.star.style.NumberingType}", "ARABIC"))) pageNumberPS~setPropertyValue("SubType", box("Short", "1")) /* Insert text in the header */ headerText~setString("Page ") headerText~insertTextContent(headerText~getEnd, pageNumberTC, .false) headerText~getEnd~setString(" of ") headerText~insertTextContent(headerText~getEnd, pageCountTC, .false) ::requires UNO.CLS Initial version