+ Reply to Thread
Results 1 to 2 of 2

Thread: Print workbook to Multiple PDF's (Each worksheet is a seperate PDF)

  1. #1
    Registered User
    Join Date
    07-30-2010
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    69

    Question Print workbook to Multiple PDF's (Each worksheet is a seperate PDF)

    Hi,

    I want to write a macro that will print off each page of a workbook and save it as a seperate PDF. I would need 1 PDF per worksheet. I would also like to be able to define the name that the PDF is saved as. This would be using Acrobat Distiller. Any help would be greatly appreciated.

    Thanks in advance

  2. #2
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    MS-Off Ver
    What does it matter?
    Posts
    3,933

    Re: Print workbook to Multiple PDF's (Each worksheet is a seperate PDF)

    Hi,

    This is some code I wrote for printing a worksheet to PDF using Distiller.

    Sub Create_PDF()
     
    'Dom Hill, June 2008
    'This code has only been tested with Adobe Acrobat 6.0 Professional
    'For this code to work the Adobe Distiller VBA library must be enabled
    'Select Tools...References in the VBA editor and check it from the list
     
    Dim tempPDFFileName As String
    Dim tempPSFileName As String
    Dim tempPDFRawFileName As String
    Dim tempLogFileName As String
     
    'define file name and path in subdirectory of file where code workbook
    'is stored called 'Print Jobs' and picks file name up from a cell
    'named as a named range called 'File_Name'
     
    tempPDFRawFileName = ThisWorkbook.Path & "\Print Jobs\" & Range("File_Name")
     
    tempPSFileName = tempPDFRawFileName & ".ps"
    tempPDFFileName = tempPDFRawFileName & ".pdf"
    tempLogFileName = tempPDFRawFileName & ".log"
     
    'Prints worksheet 'Output' as a pdf, an array of sheets can be printed if required
     
    Sheets("Output").PrintOut Copies:=1, preview:=False, ActivePrinter:="Adobe PDF", _
    printtofile:=True, Collate:=True, prtofilename:=tempPSFileName
     
    Dim mypdfDist As New PdfDistiller
     
    mypdfDist.FileToPDF tempPSFileName, tempPDFFileName, ""
     
    Kill tempPSFileName
    Kill tempLogFileName
     
    End Sub

    If you need help modifying it to loop through the worksheets let me know.

    Hope it helps,

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0