Adding page breaks in Basic

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

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
img