473,503 Members | 1,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access Reports and PdfCreator

28 New Member
Hi All,
I am trying to combine multiple access reports in one PDF using pdfcreator, however it doesn't work for me...

Can you please check the following code:

Expand|Select|Wrap|Line Numbers
  1. Sub PrintAccessReportToPDF_Early()
  2.  
  3.  
  4.     Dim pdfjob As PDFCreator.clsPDFCreator
  5.     Dim sPDFName As String
  6.     Dim sPDFPath As String
  7.     Dim sPrinterName As String
  8.     Dim sReportName As String
  9.     Dim lPrinters As Long
  10.     Dim lPrinterCurrent As Long
  11.     Dim lPrinterPDF As Long
  12.     Dim prtDefault As Printer
  13.  
  14.     Dim sReportName1 As String
  15.     '/// Change the report and output file name here! ///
  16.     sReportName = "rpt_Employee"
  17.     sReportName1 = "rpt_Employee_1"
  18.  
  19.     sPDFName = "EmployeeList_" & Format(Date, "yyyymmdd") & ".pdf"
  20.     sPDFPath = "C:\Local\Data\mr97856\Reports\" 'EmployeeList_" & Format(Date, "yyyymmdd")
  21.  
  22.     'Resolve index number of printers to allow changing and preserving
  23.     sPrinterName = Application.Printer.DeviceName
  24.     On Error Resume Next
  25.     For lPrinters = 0 To Application.Printers.Count
  26.         Set Application.Printer = Application.Printers(lPrinters)
  27.  
  28.         Set prtDefault = Application.Printer
  29.         Select Case prtDefault.DeviceName
  30.             Case Is = sPrinterName
  31.                 lPrinterCurrent = lPrinters
  32.             Case Is = "PDFCreator"
  33.                 lPrinterPDF = lPrinters
  34.             Case Else
  35.                 'do nothing
  36.         End Select
  37.     Next lPrinters
  38.     On Error GoTo 0
  39.  
  40.     'Change the default printer
  41.     Set Application.Printer = Application.Printers(lPrinterPDF)
  42.     Set prtDefault = Application.Printer
  43.  
  44.     'Start PFF Creator
  45.     Set pdfjob = New PDFCreator.clsPDFCreator
  46.     With pdfjob
  47.         If .cStart("/NoProcessingAtStartup") = False Then
  48.             MsgBox "Can't initialize PDFCreator.", vbCritical + _
  49.                     vbOKOnly, "PrtPDFCreator"
  50.             Exit Sub
  51.         End If
  52.         .cOption("UseAutosave") = 1
  53.         .cOption("UseAutosaveDirectory") = 1
  54.         .cOption("AutosaveDirectory") = sPDFPath
  55.         .cOption("AutosaveFilename") = sPDFName
  56.         .cOption("AutosaveFormat") = 0    ' 0 = PDF
  57.         .cClearCache
  58.     End With
  59.  
  60.     'Print the document to PDF
  61.  
  62.     DoCmd.OpenReport (sReportName)
  63.     DoCmd.OpenReport (sReportName1)
  64.  
  65.  
  66.     'Wait until the print job has entered the print queue
  67.     Do Until pdfjob.cCountOfPrintjobs = 1
  68.         DoEvents
  69.     Loop
  70.     'pdfjob.cPrinterStop = False
  71.     'Combine all PDFs into a single file and stop the printer
  72.     With pdfjob
  73.         .cCombineAll
  74.         .cPrinterStop = False
  75.     End With
  76.  
  77.     'Wait until PDF creator is finished then release the objects
  78.     Do Until pdfjob.cCountOfPrintjobs = 0
  79.         DoEvents
  80.     Loop
  81.     pdfjob.cClose
  82.  
  83.     'Reset the (original) default printer and release PDF Creator
  84.     Set Application.Printer = Application.Printers(lPrinterCurrent)
  85.     Set pdfjob = Nothing
  86. End Sub
  87.  
Please advise.

Thank you.
Attached Files
File Type: txt Sub PrintAccessReportToPDF.txt (2.7 KB, 876 views)
Oct 20 '10 #1
3 7665
jimatqsi
1,271 Recognized Expert Top Contributor
Before we look for the unknown, please tell us what you mean by "it doesn't work for me." In what way does it not work? And can you print individual reports to pdfs?

Jim
Oct 20 '10 #2
shimul
28 New Member
Hi Jim,

I can print individual report.

When I tried to combined, pdfcreator got freeze..

Guess problem with the following code:

Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
Thank you for your reply.
Oct 20 '10 #3
dsatino
393 Contributor
What line is break point occurring?
Oct 20 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2930
by: Joris Kempen | last post by:
Hi people, I know that the question has come around sometimes: How to open an Access Report using ASP and export it to for example RTF. I'm trying to implement the first method of David...
16
48825
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use...
5
2849
by: Steven Taylor | last post by:
Hope someone can help. I have an application whereby in order to create one document type I effectively print out 3 or 4 access reports in correct order. So the user goes to the printer,...
1
3189
by: Brian Barnes | last post by:
I've been searching using google trying to find a way to display Access Reports via ASP.NET and only finding commericial products which appear to require that the report needs to be converted every...
1
1438
by: David | last post by:
Does anyone know how to run MS Access reports from VB.net. I'd like to keep the existing reports in the database if I can. Thanks David
0
1403
by: dkurtz | last post by:
D. Lesandrini published an article some time ago about exporting Access reports as XML, and then updating those XML reports dynamically in ..NET....
16
6485
by: JoeW | last post by:
I'm utilizing a database that I created within MS Access within a program I've created in VB.NET. I am using the VB front end to navigate the information, but want to be able to print a report,...
3
5056
by: booner | last post by:
Is there any way to show an existing access database (.mdb) report inside a vb.net application? Any/all pointers much appreciated. BBB
1
2027
by: NeoDeGenero | last post by:
I have a little VBA/Access - Reports problem and I’m not sure on how to approach it: I am trying to send a Report generated by MS Access via email through the command SendObject. ...
0
2307
by: Qtip23 | last post by:
Hello All, So I have a my database information placed on a SharePoint site now that there is an immediate need for a web-based application in my division. I am able to print Access Reports...
0
7087
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5579
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.