pastertodo.blogg.se

Create landscape orientation in word
Create landscape orientation in word








  1. CREATE LANDSCAPE ORIENTATION IN WORD HOW TO
  2. CREATE LANDSCAPE ORIENTATION IN WORD INSTALL
  3. CREATE LANDSCAPE ORIENTATION IN WORD UPDATE

CREATE LANDSCAPE ORIENTATION IN WORD UPDATE

If the property does not exist, and the new orientation is Portrait, theĬode will not update the page. That case, retrieving the property returns a null reference. Of Open XML elements, the property or attribute might not exist yet. The next block of code first checks whether the Orient property of the PageSize element exists. SectPr.Descendants(Of PageSize).FirstOrDefault PageSize pgSz = sectPr.Descendants().FirstOrDefault() įor Each sectPr As SectionProperties In sectionsĭim pageOrientationChanged As Boolean = False foreach (SectionProperties sectPr in sections) If the reference is not null, the code updates the orientation as required. (If the new orientation matches the original orientation, the code will not update the page.) The code continues by retrieving a reference to the first PageSize descendant of the SectionProperties element. For each section, the code initializes a variable that tracks whether the page orientation for the section was changed so the code can update the page size and margins. The next block of code iterates through all the sections in the collection of SectionProperties elements. WordprocessingDocument.Open(fileName, True)ĭim sections = (Of SectionProperties)() WordprocessingDocument.Open(fileName, true)) Later code will use this collection to set the orientation forĮach section in turn. The code retrieves a reference to the mainĭocument part, and then uses that reference to retrieve a collection ofĪll of the descendants of type SectionProperties within the content of theĭocument. The document has changed (so that it can save the document later, if theĭocument has changed). The code maintains a Boolean variable that tracks whether True to indicate that the document shouldīe read/write. The following code first opens the document by using the Open method and sets the isEditable parameter to Theįollowing code shows an example method call. Method, pass a string that contains the name of the file to convert. Calling the Sample SetPrintOrientation Method

create landscape orientation in word

The width, height, and margins for each section. In addition, the code must manually update The section's current print orientation, the code modifies the print String fileName, PageOrientationValues newOrientation)īyVal newOrientation As PageOrientationValues)įor each section in the document, if the new orientation differs from The following code shows the SetPrintOrientation method. Modify (string) and the new print orientation ( PageOrientationValues).

create landscape orientation in word

Method accepts two parameters that indicate the name of the document to To change the print orientation of a word processing document. You can use the SetPrintOrientation method Must explicitly reference the following assemblies in your project:ĭocumentFormat.OpenXml (installed by the Open XML SDK)ĭirectives or Imports statements to compile

CREATE LANDSCAPE ORIENTATION IN WORD INSTALL

To use the sample code in this topic, you must install the Open XML SDK SetPrintOrientation method to illustrate this task. Office to programmatically set the print orientation of a Microsoft WordĢ010 or Microsoft Word 2013 document.

CREATE LANDSCAPE ORIENTATION IN WORD HOW TO

This topic shows how to use the classes in the Open XML SDK 2.5 for










Create landscape orientation in word