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
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks