'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. 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?
Solution 1:[1]
Thanks to Ricardo A I found the solution. I just select the desirable areas for printing through the code:
ActiveSheet.Range("B1:G35" & "," & "I1:K23" & "," & "O1:W33" & "," & "Y2:Y" & LastRow). _
ExportAsFixedFormat Type:=xlTypePDF, _
OpenAfterPublish:=True, _
filename:=fname, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eric |

