Print access form with PDFCreator with vba code

Hello,
I’m working in Access 2010 and I would like to use PDFCreator to change a form into a PDF file.
For the last 2 years I have used the following code (on a Windows 7 laptop, office 2010, 32 bit). Now, I want to do the same from a server (Windows 2008 server, 64 bit).
When I print the form manually (I open the form in Print Preview, then click “Print”) everything works fine. But when I try to do the same with code, PDFCreator starts up (the print monitor appears) but the job never appears in the list (I’m stuck in the loop that’s underlined).
I’ve tried updating to version 1.4.0 of PDFCreator but it doesn’t help.
Can anyone help me with this? Thanks!

Here is the code:

'Change the default printer
Set Application.Printer = Application.Printers(lPrinterPDF)
Set prtDefault = Application.Printer

'Start PFF Creator
Set pdfjob = New PDFCreator.clsPDFCreator
With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
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

'Print the document to PDF
DoCmd.OpenReport (sReportName)

'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False

'Wait until PDF creator is finished then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
pdfjob.cClose

'Reset the (original) default printer and release PDF Creator
On Error Resume Next
Set Application.Printer = Application.Printers(lPrinterCurrent)
Set pdfjob = Nothing

Hello,

from the lines you wrote, I don't think that this will start a print job:
'Print the document to PDF
DoCmd.OpenReport (sReportName)

or do you have a script in the report that will start printing? This would be the point I would check, as it looks like no file is printed and thus the loop does not terminate.

kind regards,
Philip

Hello Philip,


 

Thanks for your answer. I've checked the form properties but there is no script in the form itself to launch printing.Furthermore, on my laptop (32 bit, windows 7), everything works perfectly.


 

Could there be any other reason for the code to work on my laptop but not on a 64 bit server?


 

Kind regards,


 

Anne-Sophie

 

 

I don't see any obvious reason, but often tehre is something hidden. I would try adding a print command and see if that works on both machines.

kind regards,
Philip