+ Reply to Thread
Results 1 to 5 of 5

Print PDF files in a specific order using shell

  1. #1
    Registered User
    Join Date
    07-25-2014
    Location
    Romania
    MS-Off Ver
    2010
    Posts
    27

    Print PDF files in a specific order using shell

    Hello to all,
    I made a Excel vba code that sends pdf files one by one to a user specified printer and prints them out.
    The code works and all the files are printed, but I still have a problem with the order of the printout files. I think this is because of the network connection and the time it takes for the printer to receive the file, add it in queue and print it.
    I tried to use "application.wait now" for 4 seconds before sending the next file to the printer, but it doesn't always get the desired result.
    I also added a "application. wait now" for 30 seconds when the number of printed files is a multiple of 10.
    Is there a way to receive a response from the printer, that it received the command to print for file "1.pdf", so that I can tell shell to execute the next command?

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Print PDF files in a specific order using shell

    Hi DJohnny,

    Great question. Your problem can be solved by:
    a. using Windows API calls (too much work for me) or
    b. determining when the 'Spool Folder' is empty using the Dir() command

    For additional information about using API calls see: https://stackoverflow.com/questions/...page-while-pri

    How Windows Printing Works:
    a. On most Windows computers 'Print Spooling' is automatically enabled.
    b. When 'Print' is requested, print output is controlled by the Windows 'Print Spooler'.
    c. Each 'Print Request' creates two files in the Spool Folder (one with .SPL extension and one with a .SHD extension).
    d. The Windows 'Print Spooler' outputs to the Printer when the Printer is available.
    e. If there were no 'Print Spooler':
    (1) there could be a long wait before you could access the Computer when printing a long document.
    (2) there could be a long wait before you could access the Computer when printing any document when using a shared printer on a network.


    How the software works:
    a. Each time you print two files are created in the Spool Folder (one with .SPL extension and one with a .SHD extension).
    b. The Spool Folder is polled and returns the number of seconds it took for the Spool Folder to empty.
    c. A return value of 0 indicates a timeout occurred.
    d. A Return value of -1 indicates that the Spool folder could not be accessed (either spelled incorrectly or no 'Read Access').
    e. A Return value of -2 indicates that the user DOES NOT have 'read access' to the Spool Folder.

    NOTE: The Spool Folder may be protected, and an Administrator may have to give you 'Read Access' to the Spool Folder.

    See the following code which is included in the attached file:
    Please Login or Register  to view this content.
    To prevent typos from ruining days and weeks of work 'Option Explicit' is NEEDED at the top of each code module. This prevents errors caused by missspellings and FORCES every variable to be DECLARED (e.g. Dim i as Integer). http://www.cpearson.com/excel/DeclaringVariables.aspx

    Lewis

  3. #3
    Registered User
    Join Date
    07-25-2014
    Location
    Romania
    MS-Off Ver
    2010
    Posts
    27

    Re: Print PDF files in a specific order using shell

    Thanks for the detailed information and for the code.
    Unfortunetly, because we are using Citrix (a web based Windows server app) I cannot use the VBA code because the users are restricted from accesing the Spool folder on the server. Therefore I will take a look at the API explanation and maybe from there I can figure a way to get the printer queue or spool info.
    If I find the solution via API I will post it here. Maybe it whould be helpfull for others .

  4. #4
    Registered User
    Join Date
    02-16-2022
    Location
    hong kong
    MS-Off Ver
    2016
    Posts
    1

    Re: Print PDF files in a specific order using shell

    Hi Johnny,

    Did you find anything? I am using Citrix and would like to print pdf in specific order as well. But I don't have any solution yet. Can you share with me the vba code if you find a solution? Thanks

  5. #5
    Registered User
    Join Date
    07-25-2014
    Location
    Romania
    MS-Off Ver
    2010
    Posts
    27

    Re: Print PDF files in a specific order using shell

    Quote Originally Posted by tjmax View Post
    Hi Johnny,

    Did you find anything? I am using Citrix and would like to print pdf in specific order as well. But I don't have any solution yet. Can you share with me the vba code if you find a solution? Thanks
    Hi Tjmax,

    as a matter of fact I did find a solution. Although it works you still have to do some tweaking because of the response time between the command sending and the printer response time.
    Add rep points if this helps you


    Please Login or Register  to view this content.

+ 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. Rename all files in the same folder then print in order?
    By HXIO in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-10-2018, 09:20 AM
  2. MAcro: Print All pdf files in a specific folder
    By kalyan46 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-29-2018, 02:12 PM
  3. [SOLVED] print pages in specific order in vba macro
    By pongmeister in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-18-2016, 12:33 PM
  4. VBA to put multiple PDF files in specific order
    By Mr. Noob in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-06-2015, 10:32 AM
  5. macro to open files in specific order
    By PatrickPerth in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-30-2012, 04:06 PM
  6. Print in specific order
    By freybe06 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-24-2011, 09:31 AM
  7. print specific worksheets in specific order.
    By jarvo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-11-2006, 06:10 AM

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