GuominQiu

View Post

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/更新--

增加参数,方便调用,不仅针对当前文档设置。

分类:

技术点:

相关文章: