如何将打印到PDF宏转换为仅在当前页面上运行

时间:2019-01-28 20:32:38

标签: excel vba

目标:我有一个可为所有过滤后的列运行的宏,但是我只对运行当前字段的测试PDF文档感兴趣。

代码:

    Application.ScreenUpdating = False

Dim PDFLoc As String
Dim PDFNm As String
PDFLoc = Range("PDFPath")


On Error Resume Next
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Sheets("Parish Pivot").Activate

Set pt = ActiveSheet.PivotTables.Item(1)
For Each pf In pt.PageFields
For Each pi In pf.PivotItems
        pt.PivotFields(pf.Name).CurrentPage = pi.Name

        Columns("B:B").ColumnWidth = 37

        PDFNm = PDFLoc & "\" & Range("B11").Value & ".pdf"

        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFNm _
        , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=False, OpenAfterPublish:=False

Next
Next pf

Application.ScreenUpdating = True

感谢所有帮助。谢谢。

0 个答案:

没有答案