Word VBA modifies the code for margins, paper portrait, alignment, and so on

Source: Internet
Author: User
Tags manual

The following wapp is a predefined Word document engineering variable.

The following code is for pages with VBA code page margins, paper portrait, Alignment, Header page static, and so on.

WApp.ActiveDocument.PageSetup.LineNumbering.Active =0;//Line number

WApp.ActiveDocument.PageSetup.Orientation =microsoft.office.interop.word.wdorientation.wdorientportrait;//page orientation

WApp.ActiveDocument.PageSetup.TopMargin =wapp.centimeterstopoints (float. Parse ("2.54"))//upper margin

WApp.ActiveDocument.PageSetup.BottomMargin = wapp.centimeterstopoints (float. Parse ("2.54"))//Bottom margin

WApp.ActiveDocument.PageSetup.LeftMargin = wapp.centimeterstopoints (float. Parse ("3.17"))//left margin

WApp.ActiveDocument.PageSetup.RightMargin = wapp.centimeterstopoints (float. Parse ("3.17"))//Right margin

WApp.ActiveDocument.PageSetup.Gutter = wapp.centimeterstopoints (float. Parse ("0"))/Gutter position

WApp.ActiveDocument.PageSetup.HeaderDistance = wapp.centimeterstopoints (float. Parse ("1.5"));//Header

WApp.ActiveDocument.PageSetup.FooterDistance = wapp.centimeterstopoints (float. Parse ("1.75"));//Footer

WApp.ActiveDocument.PageSetup.PageWidth = wapp.centimeterstopoints (float. Parse ("21"))//paper width

WApp.ActiveDocument.PageSetup.PageHeight = wapp.centimeterstopoints (float. Parse ("29.7"))//paper Height

WApp.ActiveDocument.PageSetup.FirstPageTray = microsoft.office.interop.word.wdpapertray.wdprinterdefaultbin;// Paper Source

WApp.ActiveDocument.PageSetup.OtherPagesTray = microsoft.office.interop.word.wdpapertray.wdprinterdefaultbin;// Paper Source

WApp.ActiveDocument.PageSetup.SectionStart = microsoft.office.interop.word.wdsectionstart.wdsectionnewpage;// Start of section: New page

WApp.ActiveDocument.PageSetup.OddAndEvenPagesHeaderFooter = 0;//Header Footer-odd-even page difference

WApp.ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = 0;//Header Footer-Home different

WApp.ActiveDocument.PageSetup.VerticalAlignment = microsoft.office.interop.word.wdverticalalignment.wdalignverticaltop;//Page Vertical Alignment

WApp.ActiveDocument.PageSetup.SuppressEndnotes =0;//do not hide endnotes

WApp.ActiveDocument.PageSetup.MirrorMargins = 0;//does not set the home page inside and outside margins

WApp.ActiveDocument.PageSetup.TwoPagesOnOne = false;//non-duplex printing

WApp.ActiveDocument.PageSetup.BookFoldPrinting =false;//do not set manual double-sided front Print

WApp.ActiveDocument.PageSetup.BookFoldRevPrinting =false;//do not set manual double-sided back print

WApp.ActiveDocument.PageSetup.BookFoldPrintingSheets = 1;//Print default number of copies

WApp.ActiveDocument.PageSetup.GutterPos = microsoft.office.interop.word.wdgutterstyle.wdgutterposleft;//Gutter is on the left

WApp.ActiveDocument.PageSetup.LinesPage = 40;//Default page row number

WApp.ActiveDocument.PageSetup.LayoutMode = microsoft.office.interop.word.wdlayoutmode.wdlayoutmodelinegrid;// Layout mode is "Specify row grid only"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.