Results 1 to 4 of 4
  1. #1
    NeilIrving is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Posts
    2

    VBA Code to Print MS Access Reports to PDFCreator

    I print an invoice by opening a formatted Access Report that uses some "On Load" events to select appropriate graphics and notations on the invoice (different logos and such). I currently manually print this to PDF (via PDFCreator) and file the PDF in an "Invoice" folder, giving it the Invocie Number as it's docuemnt name, e.g. 12345.pdf I can then fire an email via VBA to Outlook and pick up the PDF version of the invoice from the Invoice Folder, attaching it to the email.



    THis all works fine, but I would like to automate it a little more. Instead of manually printing the PDF file from the Access Invoice document, I would like to initiate the print via VBA and have VBA tell the system what folder to save the PDF to, and then create the email and attach the PDF Invoice.

    I have most of the steps already in place, but can any one help me with the VBA code that will open the Access Report (the invoice), load the "on-load event items, print it to PDF (via PDFCreator) and save the PDF in a designated folder on the C:\Drive.

    I have already ticked the PDFCreator item in the Tools - References section of the code window.

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    15,476
    I'm not sure, but here is some code I found on a recent email. The person wanted to invoke the Windows Print Dialog from a cmd Button.
    So if you have set up pdfCreator as a "printer" this may work --- no guarantees

    Code:
    Private Sub cmdRequeryAndPrint_Click()
    DoCmd.Requery
    DoCmd.RunCommand acCmdPrint
    End Sub

  3. #3
    NeilIrving is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Posts
    2
    Thanks Orange,

    I needed a little more than that, but appreciate your getting back to me - you are the only one who did reply. Meantime I found the answer on a Microsoft Forum. For anyone who is interested, there are several answers here (http://social.msdn.microsoft.com/For...5-2984825a60be) and I am using one of them very happily now.

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    15,476
    You might identify the one that you are using. You seem to leave the reader to guess, is that what you want?

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

Similar Threads

  1. Reports print Twice
    By brharrii in forum Reports
    Replies: 5
    Last Post: 10-31-2012, 02:22 PM
  2. Requery and Print Reports?
    By Kevo in forum Programming
    Replies: 1
    Last Post: 06-22-2012, 04:46 PM
  3. Tracking values in Access reports in Code
    By dahcjohnson in forum Programming
    Replies: 3
    Last Post: 05-11-2012, 04:43 PM
  4. Print different Reports at once
    By Brian62 in forum Reports
    Replies: 5
    Last Post: 01-21-2011, 11:19 AM
  5. Option to Print Sub-reports
    By Hotwheels59 in forum Reports
    Replies: 0
    Last Post: 06-21-2010, 03:29 PM

Tags for this Thread

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 - Senior Forums