VBA操作WORD(三):設置頁面


 

Sub 設置頁面(oDoc As Document)
    With oDoc.PageSetup
        .LineNumbering.Active = False
        .Orientation = wdOrientPortrait '頁面方向為縱向
        .TopMargin = CentimetersToPoints(3.3) '上邊距
        .BottomMargin = CentimetersToPoints(3.3) '下邊距
        .LeftMargin = CentimetersToPoints(2.8)  '左邊距
        .RightMargin = CentimetersToPoints(2.6)  '右邊距
        .Gutter = CentimetersToPoints(0) '裝訂線
        .HeaderDistance = CentimetersToPoints(1.5) '頁眉
        .FooterDistance = CentimetersToPoints(1.75) '頁腳
        .PageWidth = CentimetersToPoints(21) '紙張寬
        .PageHeight = CentimetersToPoints(29.7) '紙張高
        .FirstPageTray = wdPrinterDefaultBin
        .OtherPagesTray = wdPrinterDefaultBin
        .SectionStart = wdSectionNewPage '節的起始位置:新建頁
        .OddAndEvenPagesHeaderFooter = False '不勾選“奇偶頁不同”
        .DifferentFirstPageHeaderFooter = False '不勾選“首頁不同”
        .VerticalAlignment = wdAlignVerticalTop '頁面垂直對齊方式為“頂端對齊”
        .SuppressEndnotes = False '不隱藏尾注
        .MirrorMargins = False '不設置首頁的內外邊距
        .TwoPagesOnOne = False
        .BookFoldPrinting = False
        .BookFoldRevPrinting = False '不設置手動雙面打印
        .BookFoldPrintingSheets = 1 '默認打印份數為1
        .GutterPos = wdGutterPosLeft '裝訂線位於左側
        .LayoutMode = wdLayoutModeLineGrid '版式模式為“只指定行網格”
    End With
End Sub

 

 

--2020/4/24/更新--

增加參數,方便調用,不僅針對當前文檔設置。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM