Maintaining Page Numbers in Footer when Merging Word Docs

I am in charge of writing a vb.net application that will merge existing Word documents together into one document. So far everything is working as expected, except the original page numbers in the footer need to be maintained in the final document. For example, if I have 3 documents to merge and the documents have 4 pages, 7 pages, and 3 pages, these numbers must be maintained instead of a single document with pages 1 - 14. Thank you for any help you can provide.

Hi
Thanks for your inquiry. Page numbers are upgraded automatically by MS Word. But you can try to set PageSetup.RestartPageNumbering property. Then each section numbering will start from PageSetup.PageStartingNumber. Please see the following link for more information.
https://reference.aspose.com/words/net/aspose.words/pagesetup/restartpagenumbering/
Hope this helps.
Best regards.

This was helpful thank you, but I am still having some trouble. When I set the create the section and set the starting number it does not change the ending number. For example, I have a 4 page document and a 2 page document. When I merge the two documents together I see the page numbers go as follows: 1 of 6, 2 of 6, 3 of 6, 4 of 6, 1 of 6, 2 of 6. I would like them to read: 1 of 4, 2 of 4, 3 of 4, 4 of 4, 1 of 2, 2 of 2. Is there a way to set the ending number to be the max pages within the Section?
I’m including my code so you can see if I’m implementing the code incorrectly:

Dim outDoc As Aspose.Words.Document
Dim doc As New Document(Application.StartupPath & "\MergeDoc1.doc")
doc.Sections(doc.Sections.Count - 1).PageSetup.SectionStart = Aspose.Words.SectionStart.NewPage
Dim section As Section = doc.Sections(doc.Sections.Count - 1)
section.PageSetup.PageStartingNumber = 1
section.PageSetup.RestartPageNumbering = True
outDoc = doc.Clone()
doc = New Document(Application.StartupPath & "\MergeDoc2.doc")
section = doc.Sections(doc.Sections.Count - 1)
section.PageSetup.PageStartingNumber = 1
section.PageSetup.RestartPageNumbering = True
doc.Sections(doc.Sections.Count - 1).PageSetup.SectionStart = Aspose.Words.SectionStart.NewPage
outDoc.AppendDocument(doc, ImportFormatMode.KeepSourceFormatting)
outDoc.Save(Application.StartupPath & "\NumberFormattingMergedDocOut.doc")

Hi
Thanks for your inquiry. There is no way to achieve this. You can’t also do the same using MS Word.
Best regards.

I have the similar issue. Did you find the resolution for this one. Please help me out for the exactly similar issue.

*dontompkins:
This was helpful thank you, but I am still having some trouble. When I set the create the section and set the starting number it does not change the ending number. For example, I have a 4 page document and a 2 page document. When I merge the two documents together I see the page numbers go as follows: 1 of 6, 2 of 6, 3 of 6, 4 of 6, 1 of 6, 2 of 6. I would like them to read: 1 of 4, 2 of 4, 3 of 4, 4 of 4, 1 of 2, 2 of 2. Is there a way to set the ending number to be the max pages within the Section?
I’m including my code so you can see if I’m implementing the code incorrectly:

Dim outDoc As Aspose.Words.Document
Dim doc As New Document(Application.StartupPath & "\MergeDoc1.doc")
doc.Sections(doc.Sections.Count - 1).PageSetup.SectionStart = Aspose.Words.SectionStart.NewPage
Dim section As Section = doc.Sections(doc.Sections.Count - 1)
section.PageSetup.PageStartingNumber = 1
section.PageSetup.RestartPageNumbering = True
outDoc = doc.Clone()
doc = New Document(Application.StartupPath & "\MergeDoc2.doc")
section = doc.Sections(doc.Sections.Count - 1)
section.PageSetup.PageStartingNumber = 1
section.PageSetup.RestartPageNumbering = True
doc.Sections(doc.Sections.Count - 1).PageSetup.SectionStart = Aspose.Words.SectionStart.NewPage
outDoc.AppendDocument(doc, ImportFormatMode.KeepSourceFormatting)
outDoc.Save(Application.StartupPath & "\NumberFormattingMergedDocOut.doc")

I answered your question here: https://forum.aspose.com/t/91641