简体   繁体   English

可变垂直页数打印为 PDF in VBA Excel

[英]Variable vertical number of pages to print as PDF in VBA Excel

I have a worksheet that has a print area made up of two parts (see figure below).我有一个工作表,其打印区域由两部分组成(见下图)。

在此处输入图像描述

The first, at the top, is fixed, and represents four print pages.第一个位于顶部,是固定的,代表四个打印页面。 Number four never changes.第四位永远不会改变。 The second represents a column of pages that varies in quantity.第二个代表一列数量不同的页面。 In VBA's default print as PDF option, the entire indicated region is printed, both the fixed region, the variable region and the blank region.在 VBA 的默认打印为 PDF 选项中,将打印整个指定区域,包括固定区域、可变区域和空白区域。 But I don't want the blank region.但我不想要空白区域。 I just want the blue and green region.我只想要蓝色和绿色区域。 I'm currently running the code:我目前正在运行代码:

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

Can anyone helps me?任何人都可以帮助我吗?

Thanks to Ricardo A I found the solution.感谢Ricardo A ,我找到了解决方案。 I just select the desirable areas for printing through the code:我只是 select 通过代码打印所需的区域:

ActiveSheet.Range("B1:G35" & "," & "I1:K23" & "," & "O1:W33" & "," & "Y2:Y" & LastRow). _
                        ExportAsFixedFormat Type:=xlTypePDF, _
                        OpenAfterPublish:=True, _
                        filename:=fname, _
                        Quality:=xlQualityStandard, _
                        IncludeDocProperties:=True, _
                        IgnorePrintAreas:=False

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM