在 VBA Excel 中打印为 PDF 的可变垂直页数

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

我有一个工作表,其打印区域由两部分组成(见下图)。

第一个在顶部是固定的,代表四个打印页面。第四位永远不会改变。第二个代表一列数量不同的页面。在 VBA 的默认打印为 PDF 选项中,打印整个指定区域,包括固定区域、可变区域和空白区域。但我不想要空白区域。 我只想要蓝色和绿色区域。我目前运行代码:

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

谁能帮帮我?

感谢 Ricardo A 我找到了解决方案。我只是 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