我有一个文档,它对所有页面使用相同的页脚,但我希望更改布局,并在第一页和所有其他页面上有不同的页脚。遗憾的是,我不知道如何改变页脚。我想我必须使用两个不同的页脚,但是我应该在哪里找到正确的页面呢?
Public Sub footer()
Set p_image = ActiveDocument.Shapes.AddPicture(FileName:= _
    p_path & "BwK_" & INIT.p_CO & "_XX_XX_FL_2020.jpg", _
    LinkToFile:=True, _
    SaveWithDocument:=False, _
    Width:=MillimetersToPoints(170), _
    Height:=MillimetersToPoints(20), _
    Anchor:=ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).Range)
With p_image
    .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
    .Left = MillimetersToPoints(20)
    .RelativeVerticalPosition = wdRelativeVerticalPositionPage
    .Top = MillimetersToPoints(275)
End With
End Sub发布于 2021-12-29 16:17:04
下面将将文档中的所有部分设置为具有不同的页眉和页脚的第一页。
Sub HeaderFirstPageOn()
    ' Charles Kenyon 2021-12-29
    ' Set Different First Page for Headers and Footers in all sections
    Dim iSections As Long
    Dim iCount As Long
    Let iSections = ActiveDocument.Sections.Count
    For iCount = 1 To iSections
        Let ActiveDocument.Sections(iCount).PageSetup.DifferentFirstPageHeaderFooter = True
    Next iCount
End Sub下面是一个宏,它只为第一部分设置这个宏。
Sub HeaderFirstPageOn1()
    ' Charles Kenyon 2021-12-29
    ' Set Different First Page for Headers and Footers in first section only
        Let ActiveDocument.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = True
End Sub这是一个链接到我在页眉和页脚设置上的写作。请注意,这是节设置,而不是页或文档设置,它同时适用于页眉和页脚。因此,如果您有页脚内容,您可能需要复制它的第一页标题。
发布于 2022-02-01 20:11:26
感谢您的帮助和页面上的大量文档,它帮助我找到了正确的答案:
Public Sub footer2()
    Set p_image = ActiveDocument.Shapes.AddPicture(FileName:= _
        p_path & "BwK_" & INIT.p_CO & "_XX_XX_FL_2022_Primary.png", _
        LinkToFile:=True, _
        SaveWithDocument:=False, _
        Width:=MillimetersToPoints(170), _
        Height:=MillimetersToPoints(20), _
        Anchor:=ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range)
    With p_image
        .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
        .Left = MillimetersToPoints(20)
        .RelativeVerticalPosition = wdRelativeVerticalPositionPage
        .Top = MillimetersToPoints(275)
    End With
End Sub实际上,文档只使用一个部分,所以我只需要将wdHeaderFooterFirstPage更改为wdHeaderFooterPrimary。
https://stackoverflow.com/questions/70519869
复制相似问题