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 / April 2006

Tip: Looking for answers? Try searching our database.

VBA Section Printing Problem in MSWord (Printout method)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RacinMyLancer - 19 Mar 2006 20:10 GMT
I am having trouble telling the Printout method (VBA, MS Word 2002) to print
specific SECTIONS of my document only.  I have attempted several different
techniques and have concluded that the method has trouble interpreting page
ranges... although I would be glad to find out that I am mistaken.

So: I have a document with 4 sections, page numbers as follows: s1(3),
s2(3), s3(1), s4(1).

I employ the following line of code:
[code]ActiveDocument.PrintOut Background:=True, Range:=wdPrintFromTo,
From:=vPrintRangeLower, To:=vPrintRangeHigher, Copies:=1 [/code]

,where vPrintRangeLower and vPrintRangeHigher are defined as the upper and
lower page ranges of my document.  In this case, they are set to 1 and 3, for
the first section of the document.

The result is, the ENTIRE 8 page document prints out.

So I set my ranges to 4-6, to print the second section... the result is the
same... the ENTIRE document prints out.

I also attempted the following line of code, bypassing 'wdPrintFromTo':
[code]ActiveDocument.PrintOut Background:=True, Pages:="s" & M, Copies:=1
[/code]
,where M=the current section, ie. 1,2, so that the print ranges read "s1",
"s2", etc.

The result is exactly the same.  The entire document prints out.  The
PrintOut method works perfectly for me in documents that are not divided into
sections, so my conclusion is either that the PrintOut method is not capable
of properly interpreting and handling sections, OR... there's something I'm
doing wrong.

I would REALLY love some input.  Thanks in advance.
Tony Jollans - 20 Mar 2006 00:34 GMT
When you specify pages to print you must ensure that the page numbers you
use uniquely reference the page(s) you want to print. When you have multiple
page 1's you must qualify each with section, so with this ...

   ActiveDocument.PrintOut Background:=True, Range:=wdPrintFromTo, _
   From:=vPrintRangeLower, To:=vPrintRangeHigher, Copies:=1

vPrintRangeLower needs to be "p1s1" and vPrintRangeHigher "p3s1", for
example.

Just using "p1" and "p3" as you were, prints all pages numbered 1, 2 or 3 -
in your case the whole document.

--
Enjoy,
Tony

> I am having trouble telling the Printout method (VBA, MS Word 2002) to print
> specific SECTIONS of my document only.  I have attempted several different
[quoted text clipped - 30 lines]
>
> I would REALLY love some input.  Thanks in advance.
RacinMyLancer - 07 Apr 2006 00:19 GMT
Thanks so much, Tony.  Such a simple solution, can't believe I overlooked it.
Worked like a charm!
 
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.