Sub Print_PDF_Rpt()
Dim PSFileName As String
Dim PDFFileName As String
Dim MySheet As Worksheet
Dim myPDF As PdfDistiller
Dim I As Integer
'Create PDF reports
Set myPDF = Nothing
'converts that to a PDF file.
PSFileName = "C:\temp.ps"
'Determine which column to get the report file name from
If ActiveSheet.Name = "Trend for Print" Or ActiveSheet.Name = "TN Graphs" Then
PDFFileName = PrintList.range("G" & x) & ".pdf"
ElseIf ActiveSheet.Name = "NIR Current" Or ActiveSheet.Name = "NIR LPO" Then
PDFFileName = PrintList.range("I" & x) & ".pdf"
ElseIf ActiveSheet.Name = "bounce safe" Then
If range("Typerun") = "Standard" Then
PDFFileName = range("BncSfPath") & ".pdf" 'Standard run
Else
PDFFileName = range("BncSfPathAH") & ".pdf" 'Ad Hoc run
End If
ElseIf ActiveSheet.Name = "NSF" Then
If range("Typerun") = "Standard" Then 'x
PDFFileName = range("NSFPath") & ".pdf" 'Standard run
Else
PDFFileName = range("NSFPathAH") & ".pdf" 'Ad Hoc run
End If
End If
'The way the PDFdistiller works, it prints first to a temp file...
If ActiveSheet.Name = "TN Graphs" Then
'ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True,
ActiveChart.PrintOut Copies:=1, Collate:=True, _
Preview:=False, PrintToFile:=True, _
ActivePrinter:="Acrobat Distiller", _
prtofilename:=PSFileName
Else
range(ActiveSheet.PageSetup.PrintArea).PrintOut Copies:=1, _
Preview:=False, PrintToFile:=True, Collate:=True, _
ActivePrinter:="Acrobat Distiller", _
prtofilename:=PSFileName
End If
Set myPDF = New PdfDistiller
'... then converts the temp file to a PDF file
myPDF.FileToPDF PSFileName, PDFFileName, ""
Kill "c:\temp.ps" 'Deletes the temp file
End Sub
ASKER
Set myPDF = New PdfDistiller
if PDFFileName = "" then
PDFFileName = "C:\test.pdf"
end if
'... then converts the temp file to a PDF file
myPDF.FileToPDF PSFileName, PDFFileName, ""
ASKER
ASKER
ASKER
ASKER
ASKER
Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.
TRUSTED BY
Open in new window