MS Word Print 3 Pages at a time

K

ksenzano

I have this printer that staples every print job.
I have this mail merge document where every three pages is directed to a new
recipient.
If I send the mail merge document to the printer it will print the entire
128 pages and staple them all together.
What I want is the printer to staple every three pages together. The printer
Konica has no solution for it. And I wanted to know if MS Word via VBA or
anything can send every three pages of its document as a separate print job.
 
P

Peter

Something like this might help:


Dim iPageFrom As Integer
Dim iPageTo As Integer
Dim iPages As Integer

iPages = ActiveDocument.BuiltInDocumentProperties("Number of pages")

For iPageFrom = 1 To iPages Step 3

iPageTo = iPageFrom + 3

If iPageTo > iPages Then iPageTo = iPages

Call ActiveDocument.PrintOut(Background:=True, Range:=wdPrintFromTo, From:=CStr(iPageFrom), To:=CStr(iPageTo))

Next iPageFrom

hth,

-Peter
 
K

ksen

This is doing the trick, However I'm testing it with only 9 pages of the
merge document and it is printing out 7 pages (1,2,3,4,5,6,7 ) stapled then
it prints and staples pages (7,8,9)
So it only works for the last set of 3 pages.
Could you possible comment the script as I am very new to VB. And it seems
it could be a function/math issue.
Thank you very much Peter, you are a saver.
-K
 
P

Peter

Hmm.... I checked it out again and it doesn't look like it should be behaving as you describe.
I found one error: I was setting iPageTo = iPageFrom + 3, when it should be +2 because the page range is inclusive.

Dim iPageFrom As Integer
Dim iPageTo As Integer
Dim iPages As Integer

''' get the number of pages in the document from the document properties
iPages = ActiveDocument.BuiltInDocumentProperties("Number of pages")

''' iterate through the pages, going every three
For iPageFrom = 1 To iPages Step 3

''' set the page range to print. It's inclusive, so just add two to the current page
iPageTo = iPageFrom + 2

''' check to make sure we're not going to send an invalid page to the PrintOut command
If iPageTo > iPages Then iPageTo = iPages

''' print the range of pages. Use background printing so this doesn't take forever
Call ActiveDocument.PrintOut(Background:=True, Range:=wdPrintFromTo, From:=CStr(iPageFrom), To:=CStr(iPageTo))

Next iPageFrom

Other than that, I don't see anything here that would cause the behavior you described.
I have been known to be blind sometimes, so perhaps someone else out there can eyeball it?

-Peter
 
D

Doug Robbins

See response in the other newsgroup to which you posted this. You need to
print by Sections, not Pages.

As far as Word is concerned, your pages would be numbered p1s1, p2s1, p3s1,
p1s2, p2s2, p3s2, p1s3, p2s3, p3s3, etc.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
K

ksen

Thank you again Doug! Came by to tell Peter but I see you already have.
Wish you and Peter a good day!!!
 
D

Doug Robbins

I think it was in mailmerge fields, but here is the code:

Dim i As Long
For i = 1 To ActiveDocument.Sections.Count
ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="s" & i, To:="s" & i
Next i

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
"Peter" <> wrote in message Which other NG? I'm interested to see the answer, too.

-Peter
 
P

Peter

Ah, ok. I had tested on a "normal" document, just one with several pages, and it had printed as expected, every 3 pages.

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top