在新页面部分中最初存在的pdf文件的末尾添加打印区域内容(追加) [英] Add print area content (appending) at the end of initial existed pdf file in a new page section
问题描述
为了生成报告,我使用波纹管方法创建了pdf.
For generating a report, I have create pdf with bellow approach.
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
fileName:=ThisWorkbook.path & "\rep.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
在ActiveSheet,
中指定了打印区域",Witch包含一个表,因此表的列过滤值可以通过编程方式更改,并且需要:
In the ActiveSheet,
there were specified Print Area, Witch contains a Table, so table's column filtered value have change programmatically, and need:
我希望通过更改过滤条件来改变打印区域的新面貌;
I want new face of the print area that reforms by changing filtering criteria; get appends at the end of initial pdf file quietly, without creating a new pdf file, in a new page section.
我该怎么办?
我已经在系统上安装了ADOBE Acrobat Professional,并且能够在VBA参考中添加适当的参考.
I have installed ADOBE Acrobat Professional on my system and able to add appropriate references in VBA references.
推荐答案
在解决方案中,我提供不需要Acrobat Pro. 我们假设有一个名为Table2的表. 我们还有一个帮助表(用于存储过滤的表),该表被隐藏并命名为:帮助.
In the Solution, I provide there is no need of Acrobat Pro. We suppose that we have a table which named: Table2. We have also a help sheet(to store filtered tables) which is Hiden and named: Help.
Option Explicit
Sub print_to_pdf()
Dim sh As Long
Dim rg As Range
Dim Rng As Range
Dim rw As Range
Application.ScreenUpdating = False
For Each rw In Range("Table2[#All]").Rows
If rw.EntireRow.Hidden = False Then
If Rng Is Nothing Then Set Rng = rw
Set Rng = Union(rw, Rng)
End If
Next
Rng.Copy
With Sheets("help")
.Visible = True
sh = .Cells(Rows.Count, "A").End(xlUp).Row + 2
Set rg = Range("a3" & ":" & "a" & sh - 2)
.Activate
.Cells(sh, "A").Select
ActiveSheet.Paste
ActiveSheet.PageSetup.PrintArea = rg
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=ThisWorkbook.Path & "\rep.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
.Visible = False
End With
Application.ScreenUpdating = True
MsgBox "Your PDF Has been Created with Success!!", vbInformation
End Sub
这篇关于在新页面部分中最初存在的pdf文件的末尾添加打印区域内容(追加)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!