VB.net Insert Page Number

Dear Sir

Please help to indicate how to insert page number at (odd page at left, even page at right) footer with using VB.net.

Thank you very much

Regards

Churchill

@churchilllee,

Thanks for your inquiry. We suggest you please read following articles.
Use DocumentBuilder to Insert Document Elements
Using DocumentBuilder to Modify a Document Easily

Please use the following code example to get the required output.

Dim doc As New Document()

Dim builder As New DocumentBuilder(doc)
builder.PageSetup.OddAndEvenPagesHeaderFooter = True
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary)
builder.Write("Page - ")
builder.InsertField("PAGE", "")

builder.MoveToHeaderFooter(HeaderFooterType.HeaderEven)
builder.ParagraphFormat.Alignment = ParagraphAlignment.Right
builder.Write("Page - ")
builder.InsertField("PAGE", "")

' Moves the cursor to the beginning of the body in a first section. 
builder.MoveToSection(0)

For i As Integer = 0 To 4
	builder.InsertBreak(BreakType.PageBreak)
Next
doc.Save(MyDir + "17.10.docx")

Thank you so much. It works.

Churchill