+ Reply to Thread
Results 1 to 4 of 4

Print to a pdf but then ADD existing pdfs to the newly created pdf

  1. #1
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Print to a pdf but then ADD existing pdfs to the newly created pdf

    This workbook creates via VBA (3) sheets name RED, WHITE and BLUE, then it deletes all other sheets and prints a pdf.

    I am using ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF to write my workbook to a pdf. THIS WORKS FINE.

    I have existing pdfs with known names & file locations I need to tack on to the end of the pdf I just created in excel.

    I need to loop through RED, WHITE & BLUE and
    Go to a known file location, locate the file named REDxxxxxxx.pdf and add it to the pdf, which now has 4 pages
    Go to a known file location, locate the file named WHITExxxxxxx.pdf and add it to the pdf, which now has 5 pages
    Go to a known file location, locate the file named BLUExxxxxxx.pdf and add it to the pdf, which now has 6 pages

    Can I do this in Excel 2010 via VBA?

  2. #2
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Print to a pdf but then ADD existing pdfs to the newly created pdf

    I think you would need to have Adobe acrobat (and not acrobat reader) unless you want to rebuild it every time.
    Do you have that?

    If you do - then this might help

    http://khkonsulting.com/2009/03/adob...-introduction/

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Print to a pdf but then ADD existing pdfs to the newly created pdf

    You can, but it is a significant amount of plumbing. To make my life easier in the past and keep it manageable (IMO), I use a different approach typically.

    1) I created EXCEL versions of all my "addons", saved in known locations/names

    2) When I need to create new PDF with data from a workbook PLUS the addons in a single PDF I would

    a) COPY the workbook sheet to a new temp workbook
    b) Import the addon workbooks as additional sheets to this new workbook
    c) Print the entire new workbook to a single PDF in one shot
    d) delete the temp workbook (close without saving, for instance)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    422

    Re: Print to a pdf but then ADD existing pdfs to the newly created pdf

    Good news - you don't need Acrobat! Try this:

    The AppendToPDF function will add the selected worksheet to the existing PDF, or create a new one if it doesn't already exist. Don't forget to add the Reference to Adobe Type Library. Also note, this code adds the spreadsheet PDF to the end of existing PDF, and if I understand correctly you want to do the opposite. Hopefully with some small modifications it can do what you need.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA export sheets as PDFs, merge with existing PDFs
    By wannabeexcelguy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-26-2015, 07:32 PM
  2. [SOLVED] Save copy to newly created directory in the existing folder structure
    By wpryan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-28-2015, 04:20 AM
  3. use existing creation date of workbook with newly created .saveas workbook
    By dwr0211 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-04-2011, 12:42 PM
  4. Paste into newly created tab
    By robertc12 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-21-2009, 03:27 PM
  5. Linking Newly Created Worksheets
    By bpowers in forum Excel General
    Replies: 0
    Last Post: 02-15-2009, 11:25 AM
  6. Newly Created Sheets Replacing Existing
    By degmania in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-20-2008, 04:04 PM
  7. [SOLVED] cannot copy newly created files to backup, all existing ok
    By NBaum in forum Excel General
    Replies: 3
    Last Post: 07-25-2006, 02:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1