VB Excel Macro to Print and Close a PDF

Posted on 2014-08-19
Last Modified: 2014-08-21
I am using Acrobat X and Excel 2013 and have found code to open a PDF, fill in the fields from cells in a workbook.  Now I would like to know how (from the same module) to print the PDF and then close it without Adobe asking if I want to save it.
Question by:DavidH7470
    LVL 44

    Accepted Solution

    open the PDF in read-only mode
    LVL 44

    Expert Comment

    by:Karl Heinz Kremer
    You cannot learn how to program with and for Acrobat by picking up sample code on the Internet. There is only one source that will give you all the information, and that is the Acrobat SDK:

    Take a look at the IAC (Interapplication Communication) section in the SDK documentation. You will find routines to print your document. To,prevent the save dialog, you need to reset the "dirty" flag. If that is set to false, Acrobat or Reader will not prompt you, and will just close the document.

    Author Comment

    This all seemed to work from coding found on the internet.

    Dim PDFDoc As AcroAVDoc
    Set PDFDoc = CreateObject("AcroExch.AVDoc")
    PDFDoc.PrintPagesSilent 0, 1, 2, True, True
    PDFDoc.Close True

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    PDF files have been in the limelight due to its unmatched features.  Personal documents, emails, business reports and eBooks are all converted into PDF files owing to peerless features provided by it. Adding watermark to a PDF file is a method to se…
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
    This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now