#1
|
|||
|
|||
Manual duplex printing script
I wrote a small script that will print out a document in manual duplex mode. Yes, I know MS Word already has an option for this (Manually Print on Both Sides), but I could not use that option unless I would have to reorder (reverse) the second set of pages. I'm referring to the one that needs to be flipped over.
The script below prints out all the pages in the exact order they need to be printed. The only problem is that the 'Application.PrintOut' instruction won't print the first set of pages, unless the script has been fully executed. During this time they will have a 'Spooling' status in the print queue, waiting for the script to end. What I need it to do, is... 1) print out the first set of pages; 2) present the dialog box informing me to flip over the pages, and wait for me to press the 'Ok' button; 3) then finally, print out the second set of pages. Any thoughts on how I could make the script work this way...? Right now, the whole printing process will only start AFTER pressing the 'flip over' ok button. The maximum number of prints is limited to 10, but that can be easily changed. I'd like to mention that I have no experience in VBA, although this is not my first script. Thank you, Alex Code:
Dim start_page As Integer Dim end_page As Integer start_page = InputBox("Start page:", "Print", "1") document_pages = ActiveDocument.Range.Information(wdNumberOfPagesInDocument) end_page = InputBox("End page:", "Print", document_pages) print_order = Array("1", "3", "5", "7", "9", "10", "8", "6", "4", "2") For Each current_print In print_order If current_print >= start_page And current_print <= end_page Then difference = current_print - previous_print If difference = 1 And previous_print >= 1 Then MsgBox ("Please remove and flip over the paper stack...") End If Application.PrintOut Background:=True, FileName:="", Copies:=1, Range:=wdPrintRangeOfPages, Pages:=current_print previous_print = current_print End If Next |
#2
|
||||
|
||||
Try:
Code:
Sub DuplexPrint() Application.ScreenUpdating = False Dim s As Long, e As Long, p As Long, StrPrn As String With ActiveDocument s = InputBox("Start page:", "Print", "1") e = InputBox("End page:", "Print", .ComputeStatistics(wdStatisticPages)) For p = s + (s Mod 2 - 1) To e Step 2 StrPrn = StrPrn & p & " " Next StrPrn = Replace(Trim(StrPrn), " ", ",") If StrPrn <> "" Then Application.PrintOut Background:=True, FileName:="", Copies:=1, Range:=wdPrintRangeOfPages, Pages:=StrPrn End If MsgBox ("Please remove and flip over the paper stack..."): StrPrn = "" For p = s + s Mod 2 To e Step 2 StrPrn = p & " " & StrPrn Next StrPrn = Replace(Trim(StrPrn), " ", ",") If StrPrn <> "" Then Application.PrintOut Background:=True, FileName:="", Copies:=1, Range:=wdPrintRangeOfPages, Pages:=StrPrn End If End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thank you, but I'm afraid the issue still persists. Here's how it all goes...
1) i open up a 10 pages document; 2) i print it out using any of the two scripts above; 3) the "flip over" message quickly shows up, AND at the same time the first 5 pages of the document are sent to the printer. However, the printer does NOT start printing them. In the print queue, they all show up with a "Spooling" status; 4) the printer will only start the printing process AFTER I click the "flip over" ok button. This is the point where the printer starts printing the document ("Spooling" status will end), but ALL 10 pages are printed in a row, one after another, leaving me no time to flip over the first set of pages. No difference at all when compared to a regular print job. I believe the problem lays in the simple fact that Application.PrintOut will not print the pages unless I press the MsgBox ok button, and the macro execution can end. So Application.PrintOut will only print if the script has fully executed and exited. I tried turning off the print spooler (cmd.exe - > net stop spooler) but that aggravated things even more (the printer was unavailable). I didn't notice any printer driver settings related to how the spooler works. Another approch would be to execute the script twice, with the first execution printing the first set of pages and saving the print details to a file (start/end page), and the second execution to load these details automatically and go ahead right away with the second half of prints. What would you advise me, please? Alex |
#4
|
||||
|
||||
Since the macro I posted sends two separate print jobs (one before you respond to the message box and another after you respond to it), it cannot simply be spooling. Most likely there is a delay between when the print job is sent to the printer and when it starts printing, regardless of whether you use a macro. You must wait for the first print job to complete and you have flipped the paper before responding to the message box. That said, you might get better results with:
Background:=False
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Yep, switching the 'Background' option to 'False', did all the magic! It's working as expected now! Very smooth.
Turst me, it wasn't me not waiting long enough. For some reason, the 'spooling' status would not change and the printer would not start, unless I clicked the message box button. Thank you! Alex |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Duplex printing in Publisher | Ellymoo | Publisher | 0 | 02-19-2019 04:13 AM |
Stop duplex printing | NuDawn | Word | 0 | 12-28-2016 09:06 AM |
Mixed Duplex Printing | jaygreg | Word | 2 | 01-29-2014 09:54 AM |
Duplex printing | fireman0174 | Word | 1 | 09-26-2011 01:44 AM |
Duplex Printing a merge doc | AshlandMark | Word | 0 | 02-10-2009 12:29 PM |