0

I have a following system in place

  1. One of 12 emails arrives between 5 and 7 am, in a random order
  2. Outlook rule picks up the email, and runs a VBA script that modifies, and prints parts of the some of the attached spreadsheets automatically (not all)
  3. I pick up all the printouts in the morning and manually order them into groups and staple together

What would be the best way to group the printouts before printing so that they can be printed and stapled?

2 Answers 2

0

You don't say what order you want them in...

Try this. Go to Printer Properties and click the Advanced button. Click on "Start printing after last page is spooled" and make sure that "Print spooled documents first" is ticked.

The emails will then be printed in the order that Outlook prints them. To test what Outlook does, you could try printing to file, and checking in what order the files are created. If that is not the correct order, try changing settings in Outlook so the order is the way you want it; then reconnect to the printer.

1
  • I don't think this helps in getting the separate documents stapled together by a printer Jul 20, 2015 at 8:28
0

I solved my issue and ended up doing the following:

  1. Each document is printed to *.xps files, into a folder Z:\Print using the XPS printer (PDF printing not available on work machine) in VBA, using this code:

    Application.ActivePrinter = XPSPrinter
    ActivePrinterName = Application.ActivePrinter
    If (InStr(ActivePrinterName, "XPS")) Then
        Dim Filename As String
        Filename = ActiveWorkbook.name        
        rngPrint.PrintOut Copies:=1, _
        printtofile:=True, prtofilename:=FilePath & File & ".xps"
    End If
    
  2. At 7.00 batch script (using ghostscript) converting all *.xps files to *.pdf files is scheduled . Probably we don't need two filename variables, it's a leftover from debugging.

    @echo off
    setlocal enabledelayedexpansion
    
    FOR /R Z:\Overnight\Print %%F in (*.xps) DO (
        Set filename=%%~nF%%~xF
        Set outputFilename=%%~nF%.pdf   
        Set filename2=Z:\Print\%!filename!
        Set outputFilename2=Z:\PrintPDF\%!outputFilename!
        C:\ghostxps\gxps.exe -sDEVICE=pdfwrite -sOutputFile=!outputFilename2! -dNOPAUSE !filename2!
        )
    
    exit
    exit
    
  3. Then a java program that I wrote is ran, it merges separate pdf files into desired groups (using pdfbox)

    public void combine(String outputName, String[] filenames) throws IOException, PrinterException {
    try {
        PDFMergerUtility mergePdf = new PDFMergerUtility();
        for (String filename : filenames){
            mergePdf.addSource(getFileByName(filename));
        }
        mergePdf.setDestinationFileName(outputPath+outputName+".pdf");
        mergePdf.mergeDocuments();
        System.out.println("Combined "+outputName);
       } catch (Exception e) {
         e.printStackTrace();
       }
    }
    
    1. Finally, a batch that prints all combined pdf files is ran. Delayed process kill is required, if you try to put the process kill after the invocation of the process, it'll just tell you that process is not found (even if it's right there in the task manager)

      @echo off
      setlocal enabledelayedexpansion
                  RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "\\SITE\PRINTER-BATCH"
      FOR /R Z:\CombinedPDF %%F in (*.pdf) DO (
                  Set filename=%%~nF%%~xF
                  Set filename2=Z:\CombinedPDF\%!filename!            
                  start cmd /c "timeout 15 & taskkill /f /im acrord32.exe"
                  call "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" /t !filename2!
      
                  )
      RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "\\SITE\PRINTER-DEFAULT"
      exit
      exit
      

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .