Merging the Exported pdf files with same starting names

vipulgos

Active Member
Joined
Aug 17, 2002
Messages
335
Office Version
  1. 2010
Platform
  1. Windows
I am having a code which allows me to export different pages of my report, which requires to get printed in Colour Print and some pages required to print on Black and White
Code runs like this:

VBA Code:
Worksheets("Part-1").Select
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
    FileName:=Path & "Col_Part_1", Quality:=xlQualityStandard, IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, From:=1, To:=1, OpenAfterPublish:=False


    Worksheets("Part-4").Select
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
    FileName:=Path & "Col_Part_4", Quality:=xlQualityStandard, IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, From:=1, To:=1, OpenAfterPublish:=False

Worksheets(Array("Part-1", "Part-2", "Part-3", "Decla", "Cond")).Select
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
    FileName:=Path & "B&W_P2_to", Quality:=xlQualityStandard, IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, From:=2, To:=6, OpenAfterPublish:=False
    
Sheets("RR").Select
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
    FileName:=Path & "B&W_RR", Quality:=xlQualityStandard, IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, From:=1, To:=1, OpenAfterPublish:=False

Now I want to merge all files which are having file name start by Col with name like to print in colour
and want to merge all files which are having file name start by B&W with name like to print in b&w

Please guide me how to do this
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
You could merge the PDFs with the PDFtk Server command line tool called from VBA.

The Merge_PDFs routine in the following macro merges all the PDF files in a folder to a single PDF:

To create the 2 output merged PDFs changes to the code would include 2 Dir function loops to match Col*.pdf and B&W*.pdf files:
VBA Code:
PDFfile = Dir(PDFfolder & "Col*.pdf")

VBA Code:
PDFfile = Dir(PDFfolder & "B&W*.pdf")
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top