
Originally Posted by
DerekCS
Thank you for your help. However, I have tried the guidelines of the website, and my Adobe PDF and Distiller are working fine. They can create the PDF file I requested. The problem here is the VB code I wrote is not working when it comes to the line "Set myPDF = New PdfDistiller". The distiller doesn't start off and generate the reports I have specified. I hope you can help.
Best regards,
Derek
Fortunately ( or unfortunately depending on your point of view) I have not had Adobe loaded for a very peaceful 6 months, so cannot check that, but comments from another post may help you -
that'll be this bit then
The Code uses the following external reference libraries:
Microsoft Office 10.0 Object Library (9.0 also works)
Acrobat Distiller
Go to Tools > References in the VB Editor and check them
and
Sub PrintWholeWorksheetToPDF()
Dim sPSFileName As String 'Name of PS to be created
Dim sPDFFileName As String 'Name of PDF to be created
Dim sJobOptions As String
Dim sCurrentPrinter As String 'Same current printer choice to resume at end
Dim sPDFVersionAndPort As String 'Version of Adobe
Dim appDist As cAcroDist
Set appDist = New cAcroDist
sCurrentPrinter = Application.ActivePrinter 'Save the currently active printer
sPDFVersionAndPort = "Adobe PDF on Ne01:"
sPSFileName = ThisWorkbook.Path & "\MyFileName" & ".ps" 'Name of PS file
sPDFFileName = ThisWorkbook.Path & "\MyFileName" & ".pdf" 'Name of PDF
ThisWorkbook.Sheets.PrintOut ActivePrinter:=sPDFVersionAndPort, _
PrintToFile:=True, PrToFileName:=sPSFileName 'Prints to PS
Call appDist.odist.FileToPDF(sPSFileName, sPDFFileName, sJobOptions)
'Creates PDF
Kill sPSFileName 'Removes PS
Application.ActivePrinter = sCurrentPrinter 'Change back to the original printer
End Sub
In a class module named cACroDist
Option Explicit
Public WithEvents odist As PdfDistiller
Private Sub Class_Initialize()
Set odist = New PdfDistiller
End Sub
hope something there helps, let me know how you go.
---
Bookmarks