+ Reply to Thread
Results 1 to 23 of 23

Print external pdf file

  1. #1
    Registered User
    Join Date
    07-25-2017
    Location
    Drama, Greece
    MS-Off Ver
    Microsoft Office 365
    Posts
    14

    Print external pdf file

    Good evening.
    If on a spreadsheet in column E, for example, there are the .pdf file names I want to print, how can I do this with VBA code because the files for printing listed in column E are hundreds, and the folder that contains it has thousands of files;

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Print external pdf file

    Hello taksidioths,

    Welcome to the forum!

    Does the folder only contain PDF files?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Print external pdf file

    Hello

    Add a new VBA Module to your workbook and paste the code below into it. Run the macro "PrintPDFs" from the macro dialog. While in Excel, press Alt+F8 to display the available macros.

    You can interrupt the macro by pressing the keys Ctrl+Break.

    Before you run the macro, change the variable Folder in the code to match the folder where your files are are located.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-25-2017
    Location
    Drama, Greece
    MS-Off Ver
    Microsoft Office 365
    Posts
    14

    Re: Print external pdf file

    Thanks for the interest .. Yes. If I have the answer I can transfer all the files in a folder. Naturally, the solution to be able to select files would be the best, but for the sake of principle let us be content with something general

  5. #5
    Registered User
    Join Date
    07-25-2017
    Location
    Drama, Greece
    MS-Off Ver
    Microsoft Office 365
    Posts
    14

    Re: Print external pdf file

    Thanks for the interest ..
    Unfortunately it's not working properly
    ccc.JPG
    aaa.JPG
    bbb.JPG

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Print external pdf file

    Add these two lines ..
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  7. #7
    Registered User
    Join Date
    07-25-2017
    Location
    Drama, Greece
    MS-Off Ver
    Microsoft Office 365
    Posts
    14

    Re: Print external pdf file

    Γοοδ Μορνινγ..
    Thank you again, but it still does not work properly
    sdasdasd.PNG

  8. #8
    Registered User
    Join Date
    07-25-2017
    Location
    Drama, Greece
    MS-Off Ver
    Microsoft Office 365
    Posts
    14

    Re: Print external pdf file

    Probably the problem is with 32bit Excel or 64bit Excel..
    Why did my computer work perfectly, but on the computer of my work I took the problem I show in the previous picture. Type mismatch

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Print external pdf file

    Hello taksidioths,

    This version will check if you are using 64 bit or 32 bit Windows. The previous range error has been corrected also.

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-25-2017
    Location
    Drama, Greece
    MS-Off Ver
    Microsoft Office 365
    Posts
    14

    Re: Print external pdf file

    Thank you for your patience to help me.
    The code is correct, and it works perfectly on my home computer where I did a little more code to check if there is a file or not.
    But on computer of my Job, do not work properly and the new , better code you sent me. Does the Excel settings have a problem or the file system is somehow locked?
    Attached Images Attached Images
    Last edited by taksidioths; 07-27-2017 at 10:51 AM.

  11. #11
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Print external pdf file

    How about this one ?

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  12. #12
    Registered User
    Join Date
    07-25-2017
    Location
    Drama, Greece
    MS-Off Ver
    Microsoft Office 365
    Posts
    14

    Re: Print external pdf file

    Unfortunately the same problem remains.
    Meanwhile, the code I changed to check if there is a file or not, is he, and he works perfectly at 64 bit Excel on the computer of the house.

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    07-25-2017
    Location
    Drama, Greece
    MS-Off Ver
    Microsoft Office 365
    Posts
    14

    Re: Print external pdf file

    Please Login or Register  to view this content.
    You certainly know it, but you can also enter this code to choose the file folder.

    Also, the Option Explicit command enters after Declare Function.....

  14. #14
    Registered User
    Join Date
    07-25-2017
    Location
    Drama, Greece
    MS-Off Ver
    Microsoft Office 365
    Posts
    14

    Re: Print external pdf file

    Ultimately, the answer was so unexpected.
    Contrary to what all the codes I looked at, when I changed 2 variables of LongPtr to Long, then the code worked perfectly ...
    I want to thank those who helped me..

    The code you worked on is the following.

    Please Login or Register  to view this content.

  15. #15
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Print external pdf file

    Hello taksidioths,

    I am mystified. Your code change should not work. But, who am I to argue with success. Go with what works. Great job!

  16. #16
    Registered User
    Join Date
    07-25-2017
    Location
    Drama, Greece
    MS-Off Ver
    Microsoft Office 365
    Posts
    14

    Re: Print external pdf file

    And yet he worked. A simple and bizarre solution, and it struggled me all morning trying to find the answer to other methods.

  17. #17
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Print external pdf file

    Good job and thanks for rep+.

  18. #18
    Registered User
    Join Date
    07-25-2017
    Location
    Drama, Greece
    MS-Off Ver
    Microsoft Office 365
    Posts
    14

    Re: Print external pdf file

    pause print.PNG
    I can not find how to put the problem above like a solved.
    I also can not find to start new topic.
    So I start from here.
    With the previous routine we solved the problem and so with one click I send out hundreds of files, of one page, for printing. And here comes the new problem.
    Somewhere in some memory, either the computer, or the Abobe, or printer, the pages, the files are load, or printed in random order, so then you have to try to sort the prints, which is difficult and especially time consuming. How can we send the next print only after the previous shipment has been printed on the printer?

  19. #19
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Print external pdf file

    A shell execute and infinite wait routine might work. www.cpearson.com/Excel/ShellAndWait.aspx

    While I have used the method that you used, Shell normally works for a one-off or limited multiple print.
    Please Login or Register  to view this content.
    Of course there are ways to merge print many pdfs to one pdf file. e.g. Acrobat (not Reader), PDFCreator, etc.
    Last edited by Kenneth Hobson; 07-27-2017 at 10:26 AM.

  20. #20
    Registered User
    Join Date
    07-25-2017
    Location
    Drama, Greece
    MS-Off Ver
    Microsoft Office 365
    Posts
    14

    Re: Print external pdf file

    Mr Kenneth, I thank you .
    Your code prints only one file. So if is logged in, the printer has loaded full file in memory.
    My code works with too many files of one page , so it's not clear what will be printed first, as it happens ...
    While my code is sending them sorted, the printout is approximately 50% sorted, depending on the print job of the printer

  21. #21
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Print external pdf file

    My code is designed for Adobe Reader specifically. It can do just like yours and print one file per call. Just add a loop as you did and Shell rather than ShellExecute. Reader might even be able to print several at once. Of course it might be limited if there are several with long paths or up to 15 I think. Even then, it might have a mixed printer queue.

    While one might have to code for checking printer que, the infinite shell wait method might suffice.

    I know that merging many pdfs to one pdf will work. I can show you if you tell me your preferred method from what I explained.
    Last edited by Kenneth Hobson; 07-27-2017 at 11:22 AM.

  22. #22
    Registered User
    Join Date
    07-25-2017
    Location
    Drama, Greece
    MS-Off Ver
    Microsoft Office 365
    Posts
    14

    Re: Print external pdf file

    I thank you again.
    The thought of joining all the files into one, saving it, and then printing it, seems to be very interesting.
    On the other hand, the print queue solution, when the printer is shared at the workplace, is too time consuming, and papers are also confused by other colleagues.
    However, I would like to point out that in my previous routine I choose the files I want to print through some 20.000 files, and I print only those that have the criteria I want (about 500 at a time)

  23. #23
    Registered User
    Join Date
    07-25-2017
    Location
    Drama, Greece
    MS-Off Ver
    Microsoft Office 365
    Posts
    14

    Re: Print external pdf file

    Quote Originally Posted by Kenneth Hobson View Post
    My code is designed for Adobe Reader specifically. It can do just like yours and print one file per call. Just add a loop as you did and Shell rather than ShellExecute. Reader might even be able to print several at once. Of course it might be limited if there are several with long paths or up to 15 I think. Even then, it might have a mixed printer queue.

    While one might have to code for checking printer que, the infinite shell wait method might suffice.

    I know that merging many pdfs to one pdf will work. I can show you if you tell me your preferred method from what I explained.
    The solutions I found for the print queue, the first file, the first loop, work ok, but after the first print, excel stop to work., freeze, frozen.
    As for the merging of many files, from what I saw, you have to use an external program, and in the work office, the only program we are allowed to have is the Adobe reader... and we can not used anything else
    Please help me in any method of both.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. print external documents
    By john55 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-07-2015, 03:21 PM
  2. External Data from Microsoft Query - Excel File - Causes external file to open.
    By lee1000d in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-25-2015, 02:25 PM
  3. Print external file without opening it?
    By ItalianGuy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-07-2013, 07:27 AM
  4. Print huge results in external file
    By v_nastey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-21-2012, 05:02 PM
  5. External File(s) referenced and file links change based on row cell.
    By Jimmydageek in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-23-2009, 02:59 PM
  6. Macro Print External txt file
    By DireEmblem in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-30-2008, 12:08 PM
  7. Replies: 1
    Last Post: 02-22-2006, 11:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1