Fritz Paul
asked on
Help with printing specified sheets to PDF with VBA using ExportAsFixedFormat
I am using Excel 2010.
The following code works for me to print all sheets after the second sheet.
However I want to specify a specific list of sheets to print like
This gives me a blank pdf file
Can you help please
The following code works for me to print all sheets after the second sheet.
ActiveWorkbook.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=sPDFPath & sPDFName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True, _
From: = 3
However I want to specify a specific list of sheets to print like
ThisWorkbook.Sheets(Array("Cover Page", "Net Position")).Select
and then somehow print the selection. One thing that I tried was ThisWorkbook.Sheets(Array("Cover Page", "Net Position")).Select
Selection.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=sPDFPath & sPDFName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True, _
From:=3
This gives me a blank pdf file
Can you help please
ASKER
Thanks,
I tried that now and also without the "From:=1. In both cases the selection takes place, but the resulting pdf is only two blank pages.
What does work is to hide the sheets which I don't want to print and then do the "ActiveWorkbook.ExportAsFi xedFormat .....",
I tried that now and also without the "From:=1. In both cases the selection takes place, but the resulting pdf is only two blank pages.
What does work is to hide the sheets which I don't want to print and then do the "ActiveWorkbook.ExportAsFi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have now tried so many ways and there seem to be no solution except for the negative approach, specifying what not to print. I am now content with that and don't want more of your excellent brains to be spent on this problem.
Thanks to Rgonzo1971 for his help.
Thanks to Rgonzo1971 for his help.
Pls try
ThisWorkbook.Sheets(Array(
Selection.ExportAsFixedFor
Type:=xlTypePDF, _
Filename:=sPDFPath & sPDFName, _
Quality:=xlQualityStandard
IncludeDocProperties:=Fals
IgnorePrintAreas:=False, _
OpenAfterPublish:=True, _
From:=1
Regards