工作簿中的 PDF - 页码与 PDF 对齐,而不是 Sheet

PDF'ing Workbook - Page numbers algined to PDF instead of Sheet

我有一个包含多个 sheet 的工作簿。有些 sheet 有超过 1 页,所以我在页脚 Page &[Page] of &[Pages] 中有以下内容以显示每个 sheet 中的页数。

然后我使用下面的代码将它们 PDF:

Sub PDFSheets()
    Dim ans As Variant
    Dim fPath As String
    Dim Team As String
    ans = MsgBox("Please ensure the sheets you would like to PDF are visible before running this macro. Files will be saved to your Desktop." & Chr(10) & Chr(10) & "Do you wish to continue?", vbYesNo + vbInformation, "PDF Sheets")

    If ans = vbYes Then
        Sheets("FrontSheet").Visible = True
        Sheets("Launcher").Visible = False
        Team = Sheets("FrontSheet").Range("E21").Value
        fPath = CreateObject("WScript.Shell").specialfolders("Desktop")
        Call SelectAllSheets
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fPath & "/" & Format(Now(), "yyyymmdd") & Team & " VM", _
        openafterpublish:=True, ignoreprintareas:=False
        Sheets("Launcher").Visible = True
        Sheets("FrontSheet").Visible = False
    Else
        Exit Sub
    End If
End Sub

示例场景: -Sheet 1 有 1 页,没有页脚 -Sheet 2 有 5 个页脚,页脚 Page &[Page] of &[Pages] - 然后 PDF 将在 sheet 2

的底部输出 2 of 6

这符合 PDF 的规则,而不是 sheet 中的页码。我有什么想法可以让它输出 1 of 5 而不是(如工作簿所示)?

感谢任何帮助 印花布

试试这个。

With Worksheets("Launcher").PageSetup
    .RightFooter = "&""Arial""&10 Page &P of " & .Pages.Count       
End With

此外,转到“页面布局”->“页面设置”,在“页面”选项卡中,将“第一页码”设置为 1。