Print range in Word Please help

P

Paulina Lui

I am trying to print a range of pages using word but have not been able to
do that, no matter what.
I am not sure how to pass the paramaters for the page range option, so any
suggestions are very much appreciated.

I am calling the print out method like this


Doc.PrintOut(covFalse, // Background.
covOptional, // Append.
covOptional, // Range.
covOptional, // OutputFileName.
covOptional, // // From.
covOptional, // // To.
covOptional, // Item.
COleVariant((long)1), // Copies.
covOptional, // Pages.
covOptional, // PageType.
covOptional, // PrintToFile.
covOptional, // Collate.
covOptional, // ActivePrinterMacGX.
covOptional, // ManualDuplexPrint.
covOptional, // PrintZoomColumn New with Word 2002
covOptional, // PrintZoomRow ditto
covOptional, // PrintZoomPaperWidth ditto
covOptional);

Well this print out fine, but when I try to pass the params for range, it
fails, and if I try to use Pages param instead of from/to, then it still
prints the whole document.

I have tried passing the range as
VARIANT vName;
vName.vt = VT_BSTR;
vName.bstrVal = SysAllocString(L"WdPrintOutRange.wdPrintFromTo");

and the from/to as (long) 1/(long) 2, but it failed, so then Ipassed the
pages options as below

VARIANT vName2;
vName2.vt = VT_BSTR;
vName2.bstrVal = SysAllocString(L"1-2");

But it instead prints the whole doc.

Please help!

Pauli
 
C

Cindy M -WordMVP-

Hi Paulina,
I am trying to print a range of pages using word but have not been able to
do that, no matter what.
I am not sure how to pass the paramaters for the page range option, so any
suggestions are very much appreciated.
Been a while since I did this, but looking in my old Word 95 documentation
(which was better for things like this than the VBA Help):

You need a combination of parameters. Try setting Range to 3 (prints the
range of pages specified by From and To). Then set From and To to Long
values (in .NET-speak these would be SHORT).

OR, set Range to 4 (prings the range of pages specified by Pages), then set
Pages to s STRING value that corresponds to what one would enter in the
dialog box, such as "2, 6, 8-12".

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
C

Chad DeMeyer

Also, please note that when you specify a string value for range of pages,
Word compares that against ADJUSTED page numbers, so if you have a document
with multiple sections that start over at page 1, specifying a print range
of e.g., "2-4", can have unexpected results. To work around this, you must
specify both page numbers and section numbers. So, for example, "p4s2-p3s4"
would cause page 4 of section 2 through page 3 of section 4 to be printed.

Regards,
Chad
 
P

Paulina Lui

Thanks a lot guys, god bless you, god bless you...

I was stuck on this for quite a while.

Anyways I also have to be able to control how to print, like landscape or
protrait, hwo I am doing that right now is before I print I do GetPageSetup
and then do setorientation to landscape or portrait whatever the user has
selected, I hope its the right way to go.

And one last thing is there wa way to pass options like what to print
option we have in the print dialog for powerpoitn slides through which you
can selecet "Outline View", "Slides","Notes","Handouts"....


Thansk again...

Pauli
 
C

Cindy M -WordMVP-

Hi Paulina,
Anyways I also have to be able to control how to print, like landscape or
protrait, hwo I am doing that right now is before I print I do GetPageSetup
and then do setorientation to landscape or portrait whatever the user has
selected, I hope its the right way to go.
When using the PrintOut method, the document should print in the orientation
the user has specified. If this is not the case, then there's something
seriously wrong...
And one last thing is there wa way to pass options like what to print
option we have in the print dialog for powerpoitn slides through which you
can selecet "Outline View", "Slides","Notes","Handouts"....
If you take a look at the Word File/Print dialog box, you'll see a "Print
what" dropdown list. This corresponds to the ITEM argument of the PrintOut
method.

In addition, you might want to review the settings under Tools/Options/Print.

And note that, if you want to print out what's displayed in Word's OUTLINE
view, the document should be displayed in that view before printing it out.
(There's no alternate way to tell Word to do this.)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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