locked
Word 2010 VBA Macro waits to Print All Documents Until End RRS feed

  • Question

  • I have a long (50 page) Word document, set up like this:

    • Page1
    • Page2
    • Page3 (to print on letterhead)
    • Page4 (to print on letterhead)
    • Page5
    • Page6 (to print on letterhead)

    I need to print "packets" of the sub-documents in various arrangements. For example:

    • "First Mtg" packet might contain Page5, Page1, then Page3.
    • "Second Mtg" packet might contain Page2, Page3, Page1, and Page6.

    I want the documents to print in exact "packet" order so I can take them right off the printer and be ready for my meetings. Some of the pages (noted above) need to print on letterhead and some just on blank paper.

    I want the macro to prompt the user to put letterhead in the printer when required. For example:

    • "First Mtg" macro would: print Page5, print Page1, prompt for letterhead, then print Page3.
    • "Second Mtg" macro would: print Page2, prompt for letterhead, print Page3, print Page1, prompt for letterhead, then print Page6.

    This is all VERY easy to do in a Word 2010 VBA macro EXCEPT that, for some reason, the documents don't print as I make each "Application.PrintOut" call, they all print AFTER the entire macro is finished. This means I would have to load all the paper in order (blank, blank, letterhead) or (blank, letterhead, blank, letterhead) before I start the macro--and that shouldn't be necessary.

    How do I get the macro to print each document as soon as I make the "Application.PrintOut" call?

    Thanks in advance for your help!

    Sunday, May 6, 2012 6:34 PM

Answers

  • Have you tried:

    Application.PrintOut Background:=True

    That said, the 'Background:=True' parameter is only meant to allow the macro to continue executing, not to control when the printout occurs. Conversely, 'Background:=False' may actually achieve the desired result by forcing the code execution to wait until the print job has actually been sent to the printer.


    Cheers
    Paul Edstein
    [MS MVP - Word]



    • Edited by macropodMVP Sunday, May 6, 2012 11:45 PM
    • Proposed as answer by Quist Zhang Monday, May 7, 2012 4:51 AM
    • Unproposed as answer by Quist Zhang Thursday, May 10, 2012 2:36 AM
    • Marked as answer by Quist Zhang Friday, June 1, 2012 2:45 AM
    Sunday, May 6, 2012 11:42 PM
  • the documents don't print

    "How do I get the macro to print each document as soon as I make the "Application.PrintOut" call?"

    EACH document?  There is no each document.  There is no plural - documentS.   There is ONE document. 

    The print calls are loaded into the print spool.  I am not sure this is possible.  Try macropod's Background:=True.  If that does not work, I'm afraid you may be out of luck.


    Word MVP

    • Marked as answer by Quist Zhang Friday, June 1, 2012 2:45 AM
    Sunday, May 6, 2012 11:55 PM

All replies

  • Have you tried:

    Application.PrintOut Background:=True

    That said, the 'Background:=True' parameter is only meant to allow the macro to continue executing, not to control when the printout occurs. Conversely, 'Background:=False' may actually achieve the desired result by forcing the code execution to wait until the print job has actually been sent to the printer.


    Cheers
    Paul Edstein
    [MS MVP - Word]



    • Edited by macropodMVP Sunday, May 6, 2012 11:45 PM
    • Proposed as answer by Quist Zhang Monday, May 7, 2012 4:51 AM
    • Unproposed as answer by Quist Zhang Thursday, May 10, 2012 2:36 AM
    • Marked as answer by Quist Zhang Friday, June 1, 2012 2:45 AM
    Sunday, May 6, 2012 11:42 PM
  • the documents don't print

    "How do I get the macro to print each document as soon as I make the "Application.PrintOut" call?"

    EACH document?  There is no each document.  There is no plural - documentS.   There is ONE document. 

    The print calls are loaded into the print spool.  I am not sure this is possible.  Try macropod's Background:=True.  If that does not work, I'm afraid you may be out of luck.


    Word MVP

    • Marked as answer by Quist Zhang Friday, June 1, 2012 2:45 AM
    Sunday, May 6, 2012 11:55 PM