Print to PDF and Combine with Other PDF File

doublej41

Board Regular
Joined
Mar 9, 2011
Messages
86
Hi All,

I have a file which prints specific tabs to PDF on the click of a button. I am trying to find a way to combine this with an external PDF which already exists. I saw a post from several years ago with the same question but there were no answers.

My file currently prints a two page PDF page and ideally I would like the external PDF file inserted between these two pages. Does anyone know if this is possible?

Below is the VBA used to generate the PDF. The file will PDF

VBA Code:
Sub PDFall()
Dim Answer As Variant
Answer = MsgBox("Existing PDF file will be overwritten.", vbOKCancel)
If Answer = vbOK Then
    Dim CWB As String
    CWB = ActiveWorkbook.FullName
    Dim CWBName As String
    CWBName = ActiveWorkbook.Name
    Dim PDFName As String
    PDFName = "IMI CCI Proposal " & Sheets("Input Page").Range("E8").Value & "_" & _
              Sheets("Input Page").Range("E4").Value & "_" & Sheets("Input Page").Range("F8").Value & _
              ".pdf"
    Dim PDFPath As String
    PDFPath = Replace(CWB, CWBName, "")
    
    Dim PDFfullpath As String
    PDFfullpath = PDFPath & PDFName
    
    '--------------- Hide & PDF & Unhide --------------------------------------------
    
    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Worksheets
        If ws.Range("A1").Value = "0" Then        'Skip sheets with "0" in cell A1
            ws.Visible = xlSheetHidden
        End If
    Next

    ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        PDFfullpath, Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
        False
        
    For Each ws In ActiveWorkbook.Worksheets
        If ws.Range("A1").Value = "0" Then
            ws.Visible = xlSheetVisible
        End If
    Next
Sheets("Input Page").Select
End If
End Sub
 

Some videos you may like

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

yky

Well-known Member
Joined
Jun 7, 2011
Messages
1,835
Office Version
  1. 2010
Platform
  1. Windows
Do you have Adobe Acrobat Pro?
 

doublej41

Board Regular
Joined
Mar 9, 2011
Messages
86
Do you have Adobe Acrobat Pro?
I have a PDF editor which allows me to combine and merge PDFs etc., however, I'm trying to avoid having to do this.

The end goal of this excel file is a large report output that brings in multiple files. Just trying to automate the process of joining PDFs if possible.
 

yky

Well-known Member
Joined
Jun 7, 2011
Messages
1,835
Office Version
  1. 2010
Platform
  1. Windows
Adobe Acrobat Pro has a set of API which can be used by VBA to manipulate PDF files. Does your PDF editor has something like it? You need to consult the editor's document to see if it offers such capability.
 

Watch MrExcel Video

Forum statistics

Threads
1,128,139
Messages
5,628,930
Members
416,354
Latest member
JojoMaque

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
Top