Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2007

Tip: Looking for answers? Try searching our database.

printing a document per section

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jeroen - 15 Jul 2005 11:24 GMT
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.


Doug Robbins - 15 Jul 2005 11:58 GMT
Dim i As Long
For i = 1 To ActiveDocument.Sections.Count
   ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="s" & i, To:="s" & i
Next i

Signature

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

> Can somebody help me with the following problem.
>
[quoted text clipped - 8 lines]
> I want to put this in a macro which will be activated when I push the
> printbutton.
jeroen - 21 Jul 2005 16:39 GMT
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

> Dim i As Long
> For i = 1 To ActiveDocument.Sections.Count
[quoted text clipped - 13 lines]
> > I want to put this in a macro which will be activated when I push the
> > printbutton.
fumei - 28 Dec 2007 19:06 GMT
You need to override the Word commands for printing.  You do so by writing a
procedure with the same name.

Sub FilePrint()
 ' my stuff
End Sub

will execute "your stuff" when Ctrl-p or File > Print is used.

But it will NOT execute if you click the print button!

The print button and File > Print (or Ctrl-P) are two separate procedures.

Sub FilePrintDefault()  is the procedure that is executed by clicking the
print button.

If you want to make sure your code runs you will need to override both of
them.

>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.
tamis - 28 Dec 2007 15:52 GMT
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?

> Dim i As Long
> For i = 1 To ActiveDocument.Sections.Count
[quoted text clipped - 13 lines]
> > I want to put this in a macro which will be activated when I push the
> > printbutton.
Peter Jamieson - 28 Dec 2007 16:30 GMT
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

Signature

Peter Jamieson
http://tips.pjmsn.me.uk

>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
[quoted text clipped - 22 lines]
>> > I want to put this in a macro which will be activated when I push the
>> > printbutton.
tamis - 28 Dec 2007 19:07 GMT
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.  

> Try something like
>
[quoted text clipped - 32 lines]
> >> > I want to put this in a macro which will be activated when I push the
> >> > printbutton.
Peter Jamieson - 28 Dec 2007 19:26 GMT
A simple test here (Word 2007) worked fine.

Did you ever try the simple macro with

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

?

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?

Signature

Peter Jamieson
http://tips.pjmsn.me.uk

> Ok, this sort of worked.  I first need to mention that Section 1 is a
> cover
[quoted text clipped - 45 lines]
>> >> > the
>> >> > printbutton.
tamis - 28 Dec 2007 19:58 GMT
I am working in Word 2003.

> A simple test here (Word 2007) worked fine.
>
[quoted text clipped - 72 lines]
> >> >> > the
> >> >> > printbutton.
Peter Jamieson - 28 Dec 2007 20:12 GMT
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.

Signature

Peter Jamieson
http://tips.pjmsn.me.uk

>I am working in Word 2003.
>
[quoted text clipped - 80 lines]
>> >> >> > the
>> >> >> > printbutton.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.