Changing Page Setup for Whole Document

Page setup is a set of formatting attributes which is stored in each section of a Word document. Microsoft Word Automation’s ActiveDocument.Range.PageSetup is a “shortcut” to set the same page setup for all sections of a document. Aspose.Words only provides access to the page setup of individual sections via the Section.PageSetup property so any document-wide changes to page setup must be applied for all sections.

VSTO

string mypath = "Document.docx";
Word.Application wordApp = Application;
wordApp.Documents.Open(mypath);
this.Application.ActiveDocument.Range(1,2).PageSetup.PaperSize = Word.WdPaperSize.wdPaperLetter;

Aspose.Words

Document doc = new Document( "Section.ModifyPageSetupInAllSections.doc");

// It is important to understand that a document can contain many sections and each

// section has its own page setup. In this case we want to modify them all.
foreach (Section section in doc)
	section.PageSetup.PaperSize = PaperSize.Letter;
doc.Save( "Section.ModifyPageSetupInAllSections Out.doc");

Download Sample Code