3

I am trying to automate a print job for a word document that I run daily. The task is executed as 7 print jobs on a 3 page document and requires differing sizes for the document. This is my desired result;

  1. Print 10 copies of pages 2,3 at 2 pages per sheet
  2. Print 1 copy of page 1 at 1 page per sheet
  3. Print 10 copies of pages 2,3 at 2 pages per sheet
  4. Print 1 copy of page 2 at 1 page per sheet
  5. Print 10 copies of pages 2,3 at 2 pages per sheet
  6. Print 1 copy of page 3 at 1 page per sheet
  7. Print 10 copies of pages 2,3 at 2 pages per sheet

The idea is that 40 half-sized menus for lunch and dinner are produced, and are separated evenly by 3 full-sized breakfast lunch and dinner menus for a display. This allows the half-sized menus to arrive as a number of copies that can be managed by our mat cutter (it can't handle all 40 sheets, so I have to separate them into 4 groups of 10; printing 10 copies, then 1 full-sized menu will quarter the stack of half-sized menus). This process consumes 43 sheets of paper.

I am trying to develop a VBA script that will accomplish this, but the trouble I'm encountering is that I cannot control the number of pages per sheet in the print job, and the PageSetup libraries alters the document itself as opposed to the print job.

Is there any way that I can control the number of pages per sheet using a VBA script in the same manner as the printer dialog box?

Sub DailyMenuPrintJob()

    Dim doc As Document
    Set doc = ActiveDocument

    ' Print 10 copies of pages 2–3, 2 pages per sheet (half-sized)
    doc.PageSetup.TwoPagesOnOne = True
    doc.PrintOut Range:=wdPrintFromTo, From:="2", To:="3", _
                 Copies:=1
    ' === Print Breakfast Display (Page 1) ===
    doc.PageSetup.TwoPagesOnOne = False
    doc.PrintOut Pages:="1", Copies:=1
    ' Print 10 copies of pages 2–3, 2 pages per sheet (half-sized)
    ActiveDocument.PageSetup.TwoPagesOnOne = True
    doc.PrintOut Range:=wdPrintFromTo, From:="2", To:="3", _
                 Copies:=1
    ' === Print Lunch Display (Page 2) ===
    doc.PageSetup.TwoPagesOnOne = False
    doc.PrintOut Pages:="2", Copies:=1
    ' Print 10 copies of pages 2–3, 2 pages per sheet (half-sized)
    doc.PageSetup.TwoPagesOnOne = True
    doc.PrintOut Range:=wdPrintFromTo, From:="2", To:="3", _
                 Copies:=1
    ' === Print Dinner Display (Page 3) ===
    doc.PageSetup.TwoPagesOnOne = False
    doc.PrintOut Pages:="3", Copies:=1
    ' Print 10 copies of pages 2–3, 2 pages per sheet (half-sized)
    doc.PageSetup.TwoPagesOnOne = True
    doc.PrintOut Range:=wdPrintFromTo, From:="2", To:="3", _
                 Copies:=1

End Sub


Half Sized Print Jobs

Full Sized Breakfast Print Job Example

I've tried alternating between PageSetup.TwoPagesOnOne = False/True, but that does something completely different to setting two pages per sheet in the dialog box. Printing pages 2 & 3 works fine, but augmenting their size does not.

3
  • 1
    As far as I'm aware you can't do it using VBA alone. PageSetup object in Word VBA affects the document layout itself, not the print job settings like "Pages per sheet" which is a printer-level configuration. You would need to use Windows Shell or WScript to automate it. Commented Jul 23 at 22:47
  • 1
    Assuming this is Windows and can set up "new" printers, It may be easier to do this by creating new logical printers ,one for each print layout you need, setting the relevant properties for each printer, and switching between the logical printers using Application.ActivePrinter. Depends on the printer and your networking setup how that might work.. NB if you add a printer manually in Windows control panel/Settings, you need the same Port as the existing printer, then each logical printer appears as a tab in the "main" printer's settings. Commented Jul 24 at 7:09
  • Closest potentially-helpful reference I can find: stackoverflow.com/a/40549637/2727437 Commented Jul 26 at 14:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.