Print Page Range Question 
Author Message
 Print Page Range Question

Hi,

I have a macro that selects certain files from a folder
and prints them.  My problem is that the documents are all
different lengths, but I still need to print from page 3
through the second to last page.  

I have placed the bit of code below that apparently isn't
right.  

Dim NoPages, NoP
NoPages = ActiveDocument.Content.ComputeStatistics
(wdStatisticPages)
NoP = NoPages - 1
ActiveDocument.PrintOut Range:=wdPrintFromTo, Item:= _
wdPrintDocumentContent, Copies:=1, From:="3", To:="NoP"

Any tips or suggestions would be very welcome.

Thanks,

Carolyn R.



Wed, 17 Aug 2005 03:26:22 GMT  
 Print Page Range Question
Hi, Carolyn,

The error is in trying to convert the numeric variable NoP into a string by
putting quotes around its name. All you get from that is a string containing
the actual characters "N", "o", and "P", not the string equivalent of the
numerical value of the variable. Instead, use this at the end of the
PrintOut command:

To:=Str(NoP)

Then if the last page is page 73, NoP will have the value 72 and the To
parameter will receive the string "72".

--
Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://www.mvps.org/word

Quote:

> Hi,

> I have a macro that selects certain files from a folder
> and prints them.  My problem is that the documents are all
> different lengths, but I still need to print from page 3
> through the second to last page.

> I have placed the bit of code below that apparently isn't
> right.

> Dim NoPages, NoP
> NoPages = ActiveDocument.Content.ComputeStatistics
> (wdStatisticPages)
> NoP = NoPages - 1
> ActiveDocument.PrintOut Range:=wdPrintFromTo, Item:= _
> wdPrintDocumentContent, Copies:=1, From:="3", To:="NoP"

> Any tips or suggestions would be very welcome.

> Thanks,

> Carolyn R.



Wed, 17 Aug 2005 05:38:44 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Very simple Range question - beggining the range on 3rd page onwards

2. Printing Specific or Range of Pages

3. Programmatically Printing a Range of pages.

4. Disabling the page range on the Print Dialog

5. ComonDialog print page range

6. printing page ranges?

7. Printing out a range of pages in WebBrowser control

8. printing a selsct range of pages

9. printing a range of pages

10. Another question about range objects... inserting page break

11. How can I set a Range from Page X to Page Y

12. Print range from print dialogue box

 

 
Powered by phpBB® Forum Software