Greetings!
I have a proper reference to PDFCreator; there is an installed PDFCreator ‘printer’; the code I’m using stops at this IF statement because it returns false… Entire procedure follows the snippet.
Any ideas?
If .cStart("/NoProcessingAtStartup") = False Then
'then reset default.
Set Application.Printer = Application.Printers(myDefPrt)
MsgBox “Can’t initialize PDFCreator.”, vbCritical + _
vbOKOnly, “PrtPDFCreator”
Exit Sub
End If
--------------------------------------------------------------------------------
Sub WriteToPDFCreator()
Dim pdfjob As PDFCreator.clsPDFCreator
Dim sPDFName As String
Dim sPDFPath As String
'/// Change the output file name here! ///
sPDFName = “testPDF.pdf”
sPDFPath = “C:\InvKPI”
Dim myDefPrt As String
'get current default printer.
myDefPrt = Application.Printer.DeviceName
Set pdfjob = New PDFCreator.clsPDFCreator
With pdfjob
Stop
If .cStart("/NoProcessingAtStartup") = False Then
'then reset default.
Set Application.Printer = Application.Printers(myDefPrt)
MsgBox “Can’t initialize PDFCreator.”, vbCritical + _
vbOKOnly, “PrtPDFCreator”
Exit Sub
End If
.cOption(“UseAutosave”) = 1
.cOption(“UseAutosaveDirectory”) = 1
.cOption(“AutosaveDirectory”) = sPDFPath
.cOption(“AutosaveFilename”) = sPDFName
.cOption(“AutosaveFormat”) = 0 ’ 0 = PDF
.cClearCache
End With
’ change the printer
Set Application.Printer = Application.Printers(“PDFCreator”)
’ do your printing here…
‘Print the document to PDF
’ Application.ActivePrinter = “PDFCreator1” ’ didn’t work
'activedocument.PrintOut
DoCmd.OpenReport “rptLocationsByType”, acViewPreview, , , acHidden
DoCmd.PrintOut acPrintAll
'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
Loop
pdfjob.cPrinterStop = False
'Wait until PDF creator is finished then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
Loop
pdfjob.cClose
Set pdfjob = Nothing
'then reset default.
Set Application.Printer = Application.Printers(myDefPrt)
End Sub
---------------------------------------------------
Many thanks! -Bill-
Hi,
can you mail us this as access document so we can do some testing?
regards,
Robin