首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Excel VBA指定word文档标题位置

Excel VBA指定word文档标题位置
EN

Stack Overflow用户
提问于 2014-04-02 13:00:57
回答 1查看 3.6K关注 0票数 1

我正在尝试编写一些excel vba来更改word文档中页眉/页脚的位置。我想用VBA更改的项目是“头到顶”。

我找不到任何解决方案--即使我记录了一个单词宏并改变了位置,宏也是空白的。

有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2014-04-02 14:16:18

我找不到任何解决方案--即使我记录了一个单词宏并改变了位置,宏也是空白的。

我可以很容易地记录一个宏的VBA字。这就是我得到的

代码语言:javascript
复制
Sub Macro2()
'
' Macro2 Macro
'
'
    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
        ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
        ActivePane.View.Type = wdOutlineView Then
        ActiveWindow.ActivePane.View.Type = wdPrintView
    End If
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    With Selection.PageSetup
        .LineNumbering.Active = False
        .Orientation = wdOrientPortrait
        .TopMargin = InchesToPoints(1)
        .BottomMargin = InchesToPoints(1)
        .LeftMargin = InchesToPoints(1)
        .RightMargin = InchesToPoints(1)
        .Gutter = InchesToPoints(0)
        .HeaderDistance = InchesToPoints(0.7)
        .FooterDistance = InchesToPoints(0.5)
        .PageWidth = InchesToPoints(8.5)
        .PageHeight = InchesToPoints(11)
        .FirstPageTray = wdPrinterDefaultBin
        .OtherPagesTray = wdPrinterDefaultBin
        .SectionStart = wdSectionNewPage
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .VerticalAlignment = wdAlignVerticalTop
        .SuppressEndnotes = False
        .MirrorMargins = False
        .TwoPagesOnOne = False
        .BookFoldPrinting = False
        .BookFoldRevPrinting = False
        .BookFoldPrintingSheets = 1
        .GutterPos = wdGutterPosLeft
    End With
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

你真正想要的是.HeaderDistance = InchesToPoints()

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22812335

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档