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.

       ActiveWorkbook.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:=sPDFPath & sPDFName, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=False, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=True, _
        From: = 3

Open in new window


However I want to specify a specific list of sheets to print like

   
 ThisWorkbook.Sheets(Array("Cover Page", "Net Position")).Select

Open in new window

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

Open in new window


This gives me a blank pdf file

Can you help please
Fritz PaulAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

Pls try

ThisWorkbook.Sheets(Array("Cover Page", "Net Position")).Select
   
   
    Selection.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:=sPDFPath & sPDFName, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=False, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=True, _
        From:=1

Regards
0
Fritz PaulAuthor Commented:
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.ExportAsFixedFormat .....",
0
Fritz PaulAuthor Commented:
I still get blank pages.

Thanks a lot for your help, but I think I will just work with hiding those pages that I don't want to print.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fritz PaulAuthor Commented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.