Print a PDF file using VBA

  • Hi all


    I'm using Excel 2010 and have Adobe Reader 11.


    I'm trying to make a code in VBA that can print a specific PDF file. It's OK if the file opens first but it not necessary.


    The file name change from time to time but it’s written in a specific cell in Excel. Let us say that it’s A1 in sheet1. The path is the same every time so that can be written directly in the code.


    I have found this code on WWW but it doesn’t work for me.



    I do hope that someone can help me.


    Thank you in advance

  • Re: Print a PDF file using VBA


    For AcroRd32.exe, pass command line parameters using Shell().


    /n - Launch a new instance of Reader even if one is already open
    /s - Don't show the splash screen
    /o - Don't show the open file dialog
    /h - Open as a minimized window
    /p <filename> - Open and go straight to the print dialog
    /t <filename> <printername> <drivername> <portname> - Print the file the specified printer.


    Be sure to surround the full path to the EXE and the pdf full path filename with double quote marks.

  • Re: Print a PDF file using VBA


    Hi Kenneth


    Thank you for the answer. Bur don't understand what you mean about the pass command line parameters. Where shall I put in the letters you write?


    Where in the code is the mistake that do that the code don't work??


    Thank you in advance
    /Mads

  • Re: Print a PDF file using VBA


    You can hard code the path to your EXE as I said. I added an API method to find the path. The command line parameters don't work as well with the newer Adobe Acrobat Reader DC.


  • Re: Print a PDF file using VBA


    Hi MrRedli and Kenneth


    Both of them works perfectly. Thank you to you both.


    Now I can see that both of the codes print the Pdf file in A4. Is it possible to have the code to prnt A3 as the PDF file are savede in??


    Thank you in advance.

  • Re: Print a PDF file using VBA


    Hi Kenneth


    I though so that Excel can't control Adope's printing menu. I have made the changes in Adope and all works perfect now. Thanks for your time and your help.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!