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;
- Print 10 copies of pages 2,3 at 2 pages per sheet
- Print 1 copy of page 1 at 1 page per sheet
- Print 10 copies of pages 2,3 at 2 pages per sheet
- Print 1 copy of page 2 at 1 page per sheet
- Print 10 copies of pages 2,3 at 2 pages per sheet
- Print 1 copy of page 3 at 1 page per sheet
- 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
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.
PageSetupobject 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.