Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.5k views
in Technique[技术] by (71.8m points)

vba - Exporting multiple pages to PDF in a specific order

I am trying to export pages from two different sheets of a workbook as 1 PDF.

However, I want the pages to be in this order: 1 page from Sheet1, 5 pages from Sheet2, 2 pages from Sheet1.

At the moment I am exporting these as 3 seperate PDFs and then merging them afterwards in another application.

The code I have been using is below:

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=sPath & quotept1filename, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, From:=1, To:=1, OpenAfterPublish:=False

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=sPath & quotept2filename, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, From:=2, To:=3, OpenAfterPublish:=False

Sheets("PPA Print Ready Quote").Select

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=sPath & optionsfilename, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, From:=1, To:=NumberOfOptions, OpenAfterPublish:=False

How can I get them to print as one PDF in the order I want?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It may not seem like the best way, but I personally use a driver such a PrimoPDF to do this. By printing all the pages required to PrimoPDF you will gain one pdf file in the same order that it would appear if you were sending to a standard printer.

It can be downloaded for free here http://www.primopdf.com/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...