This is a topic that was previously entered by me. In that post, I needed to add new pagestyles. I solved that, but now all pages have page 1. it should be 1 to 13. I think that to go from one page style to another I need to add page breaks (I think). I cannot find the method to do this. Hopefully this will allow the page counting to go correctly
Thank you
John
If you mention a different question, please post a link to it.
Add Page Break to some position of Text cursor
Sub addPageBreak
dim oDoc as object, oCur as object, i%
oDoc=Stardesktop.loadComponentFromUrl("private:factory/swriter", "_blank", 0, array()) 'new document
oCur=oDoc.Text.createTextCursor
for i=1 to 5 'add some paragraphs to document
oCur.String="a" & i
oDoc.Text.insertControlCharacter(oCur.End, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false) 'insert Enter
oCur.gotoEnd(false)
next i
with oCur 'move cursor to some position
.gotoEnd(false)
.goLeft(4, false)
.BreakType=com.sun.star.style.BreakType.PAGE_BEFORE 'set Page Break
end with
End Sub
I suppose you search macro for Writer and not Calc
Sorry for taking so long to respond. Although I did find another way around the problem, thank you. It explains a lot.
Thank you
John
A workaround without any explanation isn’t a solution.
You asked for Basic code.
I thought that my solution was to specific to what I was doing. However you are right I should still share it:
1 - After initialization the first thing I d is create all the sheets. This gives the total number of pages.
2 - Each month, and summary sheet are referenced in an array. Numbered from 0(Summary to 12(Dec)
3 - When I am creating the page layout, I pass the routine the Document and the month number
4 - I set the Right of the footer to:
HText =.RightText
HText.String = "Page " & MonthNo +1 & " of " & doc.sheets.count
All pages are numbered correctly.
This, however, will only work if all pages are created initially, and there is a way of getting each page number.
John