【发布时间】:2017-12-05 22:28:11
【问题描述】:
我有一个包含多张工作表的工作簿。有些工作表超过 1 页,所以我在页脚 Page &[Page] of &[Pages] 中有以下内容以显示每张工作表中的页数。
然后我使用下面的代码将它们 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 将在工作表 2 的底部输出 2 of 6
这是遵守 PDF 的规则,而不是工作表中的页码。有什么想法可以将其输出1 of 5(如工作簿所示)?
任何帮助表示赞赏 印花布
【问题讨论】:
标签: vba excel pdf spreadsheet