Results 1 to 10 of 10
  1. #1
    Join Date
    Jul 2009
    Posts
    15

    Unanswered: from Access report to pdf

    Hi

    I need to print some Access reports to pdf.

    I'd like to do this with VBA code only, without using other applications.

    Does someone know if it is possible?

    Thank you

    Regards,

    Paolo

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    What version of Access. 2007 has it built in (though I think you have to download something). Many of us use this for previous versions:

    ReportToPDF
    Paul

  3. #3
    Join Date
    Jul 2009
    Posts
    15
    Hi
    thank you
    i have both Access 2007 and 2003 but I'm most interested in the 2003 version. Is there a way not to install dll just using code? (I've got a pdf printer, I don't need to directly convert reports to pdf)

  4. #4
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    I am not sure what you mean. If you edit the report's Page Setup, you can have the report print to the PDF printer all of the time.

    An option that I am currently using is RunReportAsPDF. You can search for it on the Internet. You can add the code to a module in Access and it will print an Access report to a PDF. The reason I am using it is I needed to be able to specify a filename without prompting for it. The code edits a couple of registry settings to store the filename. Then Adobe creates the PDF. I don't think the code works with anything other than Adobe.

  5. #5
    Join Date
    Jul 2009
    Posts
    15
    Mm... I'd prefer not to edit the register

    I write what I mean:

    I want use a form with a button. When I press it, I'd like the pc to do:

    -print the report X
    -use the printer Y (always the same which creates pdf, which is not the default one)
    -save pdf with the name Z (always the same every time I press the button recalling the code)

    Do you think this is not possibile just using VBA code?

    Otherwise, is it not possible to change the default printer momentarily?

  6. #6
    Join Date
    Jul 2009
    Posts
    15
    well, maybe it is simpler to modify the Page Setup settings.
    Thank you for your help!

  7. #7
    Join Date
    Jul 2009
    Posts
    15
    ok I did it
    but it always ask me where I want to save the pdf and with which name.
    Is it possible to avoid this situation?
    thank you

  8. #8
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    Are you using Adobe? The only way I know of to specify a filename is by setting the registry setting. Adobe checks the setting to see if it has been defined. If so, it uses that for the filename. Otherwise it prompts for the filename. It also resets the registry setting if a filename was saved there. So that the filename is only used once. You have to resave the filename if you want to create a new PDF with the same filename.

  9. #9
    Join Date
    Jul 2009
    Posts
    15
    I found a solution by setting the printer
    I save files on desktop, without having to do with boring prompts!
    It is not the best, but I had not to modify register settings.
    thank you for all your advice!

  10. #10
    Join Date
    May 2009
    Posts
    104
    I have been playing around trying to get the same thing working, I'm not sure if 2003 has this same capabilities but you can copy and paste the code and see what happens.

    VB-Code

    Private Sub Command30_Click()
    DoCmd.OpenReport "rptCoatedPartCache", acViewPreview
    DoCmd.OutputTo acOutputReport, "rptCoatedPartCache", acFormatPDF, _
    "U:\POBushingsAndPins\" & "PurchaseOrder" & [PurchaseOrder#] & ".pdf", False
    End Sub

    This will open the report rptCoatedPartCache in print preview mode and outputs the file in .pdf format to the location on our shared company drive U:\ to the folder POBushingsAndPins and names the file PurchaseOrderXXXX.pdf, with the XXXX being the purchase order number from the report. It will dynamically name the file whatever field you choose from the database. This doesnt use the Print to PDF feature added in by adobe, it uses the output to pdf built into Access 2007, if 2003 doesn't have this maybe you can install it.
    Hope this helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •