printing a document per section

J

jeroen

Can somebody help me with the following problem.

I have documents with several sections, and I want to send each section as a
standalone printjob to the printer.

For example: One document which contains 3 sections will lead to 3 separate
printjobs.

I want to put this in a macro which will be activated when I push the
printbutton.
 
D

Doug Robbins

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


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

jeroen

Thnx this those solve the first problem of my case now I want to activate
this macro when a user hits the default print button is there a possibility
to add this macro to the default print button. For example: I hit Ctrl-p
and ok and when the macro is in the document it will execute as below.

If anybody can help me with that I would be immense grateful
 
T

tamis

I am a beginning programmer. Here is my situation. I have a macro that I
need to print Section1 by itself. I need to print Section 2 twice and then
the rest of the sections until the end. I think the code below will work but
am not sure how to modify it for my macro. Can you help?
 
P

Peter Jamieson

Try something like

Dim i As Long
ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="s1", To:="s1"
ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="s2", To:="s2",
Copies:=2
For i = 3 To ActiveDocument.Sections.Count
ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="s" & i, To:="s" & i
Next i
 
T

tamis

Ok, this sort of worked. I first need to mention that Section 1 is a cover
letter with a logo in the header, that did not print. It also only printed
about half of the page. Then it did not print sections 2, 3 or 4, but did
print sections 5-9.
 
P

Peter Jamieson

A simple test here (Word 2007) worked fine.

Did you ever try the simple macro with

?

But what happens, for example, if you just do:

ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="s1", To:="s1"

?

A few things that might affect the results:
a. try disabling/enabling background printing.
b. Is your first section set up to print to a different output tray from
the rest?
c. Are all your sections single-sided, double-sided, or is there a mix?
d. Do you have different types of section break, e.g. continuous, even
page, odd page, next page?
 
T

tamis

I am working in Word 2003.

Peter Jamieson said:
A simple test here (Word 2007) worked fine.

Did you ever try the simple macro with


?

But what happens, for example, if you just do:

ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="s1", To:="s1"

?

A few things that might affect the results:
a. try disabling/enabling background printing.
b. Is your first section set up to print to a different output tray from
the rest?
c. Are all your sections single-sided, double-sided, or is there a mix?
d. Do you have different types of section break, e.g. continuous, even
page, odd page, next page?
 
P

Peter Jamieson

Works fine in Word 2003 too (this time on Win XP - the other test was on
Vista). If you have looked at everything else I mentioned and nothing seemed
out of the ordinary, maybe you should try looking at your Control
Panel/Printers option (e.g. I might try suspending printout and seeing if
the number of jobs I expected - one for each time you call the Printout
mechanism - appears in the Print queue.
 

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