PDA

View Full Version : Convert to PDF on Legal Size Paper



MMQQ
07-17-2008, 03:41 PM
Hello,The following code will convert my current excel doc to pdf. But how can I change it so that it knows to converted to legal size for when people print the pdf doc? In Excel it is set to legal size already.Sub PDFConversionAndSave(TabNametoPrint As String)Dim OriginalPrinter As StringDim pdfDist As New ACRODISTXLib.PdfDistiller'unless user of this template manually goes to Print, Select Adobe PDF, and in' properties, uncheck [Do not send fonts to "Adobe PDF"], macro will crash and we'll have to be rerun.'As of Jan 08, checked google and various sites saying that currently this step' can't be programmed, so must be done manually. 'Generate PS file in selected folder Worksheets(TabNametoPrint).Activate Application.DisplayAlerts = True 'Print to PS file in nominated folder ActiveWindow.SelectedSheets.PrintOut Copies:=1, preview:=False, ActivePrinter:=PDFPrinter, printtofile:=True, collate:=True, prtofilename:=FilePathToSave & FileNameToSave & ".ps" 'Convert PS to PDF using the method from PDFDistiller class pdfDist.FileToPDF FilePathToSave & FileNameToSave & ".ps", FilePathToSave & FileNameToSave & ".pdf", "" Application.DisplayAlerts = True Set pdfDist = Nothing 'Clears the pipes Kill (FilePathToSave & FileNameToSave & ".ps") Kill (FilePathToSave & FileNameToSave & ".log")End SubThanks,MM
Sorry...wrap tabs icon disabled on my computer.

Dr.K
07-17-2008, 04:46 PM
I'm pretty good with the PDF Objects, so I'd like to help... but your code is giving me a headache.

Could you please fix the indentation?

MMQQ
07-17-2008, 06:46 PM
Sorry about that. Here it is again:

PDFConversionAndSave(TabNametoPrint As String)
Dim OriginalPrinter As String
Dim pdfDist As New ACRODISTXLib.PdfDistiller

Worksheets(TabNametoPrint).Activate
Application.DisplayAlerts = True
ActiveWindow.SelectedSheets.PrintOut Copies:=1, preview:=False, ActivePrinter:=PDFPrinter, printtofile:=True, collate:=True, prtofilename:=FilePathToSave & FileNameToSave & ".ps"

pdfDist.FileToPDF FilePathToSave & FileNameToSave & ".ps", FilePathToSave & FileNameToSave & ".pdf"

Application.DisplayAlerts = True
Set pdfDist = Nothing

Kill (FilePathToSave & FileNameToSave & ".ps"
Kill (FilePathToSave & FileNameToSave & ".log"
End Sub