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

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
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,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

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