Results 1 to 4 of 4
  1. #1
    jlk is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Nov 2012
    Location
    Australia
    Posts
    11

    Exporting a report to PDF, How do you add code to open the pdf

    Hello!



    I have a report that I export to PDF through code. I have this code attached to a button on my main form. When the code runs it saves the PDF to my selected folder ok but I can not work out what code to added to get the pdf file to open automatically after the export.

    This is my code:

    DoCmd.OutputTo acOutputReport, "rptFINALCentreTotals", acFormatPDF, , , , , acExportQualityScreen


    Is anyone able to help me to work out what code needs to be added to have the pdf file open after export?

    Many Thanks

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Add "True" for Autostart as below
    DoCmd.OutputTo acOutputReport, "rptFINALCentreTotals", acFormatPDF, , True, , , acExportQualityScreen

  3. #3
    roaftech is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Nov 2012
    Location
    Romania
    Posts
    65
    An alternative solution, which may be more appropriate to older versions of Access, is to print to something like PDFcreator, where you have that programme's native controls available too.

    Assuming that you have the pdf writer as your default printer, the basic code looks like this:
    --------
    Private Sub Print_Form_Click()
    On Error GoTo Err_Print_Form_Click

    DoCmd.PrintOut acSelection

    Exit_Print_Form_Click:
    Exit Sub

    Err_Print_Form_Click:
    MsgBox Err.Description
    Resume Exit_Print_Form_Click

    End Sub
    ---------
    As an aside, I always output to pdf before committing to paper - apart from giving a record copy of the document for digital filing, it also allows me to check formatting, spelling and content before using any paper or toner.

  4. #4
    jlk is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Nov 2012
    Location
    Australia
    Posts
    11
    Thank you both for your responses. Using True worked perfectly
    Much appreciated.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. VBA Code to Open Form
    By kevins in forum Programming
    Replies: 6
    Last Post: 10-23-2012, 06:53 AM
  2. Replies: 1
    Last Post: 05-03-2012, 02:25 PM
  3. Open Exclusive Code
    By AKQTS in forum Access
    Replies: 2
    Last Post: 08-11-2011, 10:51 AM
  4. Exporting report to PDF
    By jgelpi16 in forum Reports
    Replies: 1
    Last Post: 08-06-2011, 08:58 PM
  5. Replies: 2
    Last Post: 02-26-2010, 08:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums