Print certain pages only

15,006

Range:=wdPrintRangeOfPages needs to be added along with Pages.

For example:

Application.PrintOut FileName:="", Copies:=2, Range:=wdPrintRangeOfPages, Pages:="2,6-10"
Share:
15,006
oshirowanen
Author by

oshirowanen

Updated on June 05, 2022

Comments

  • oshirowanen
    oshirowanen almost 2 years

    I have the following code which works fine:

    Application.PrintOut FileName:="", Copies:=2
    

    This prints my 10 page document twice.

    I now want to use the pages option to specify only certain pages to print out:

    Application.PrintOut FileName:="", Copies:=2, Pages:="2, 6-10"
    

    I was expecting it to print out pages 2 and 6 to 10 twice, i.e. 2,6,7,8,9,10,2,6,7,8,9,10, but instead it just printed all 10 pages twice.

    I am using VBA in Word 2010.

    Any idea what I'm doing wrong?


    RESOURCES:

    From Microsoft Developer Network:

    Pages - Optional - Variant - The page numbers and page ranges to be printed, separated by commas. For example, "2, 6-10" prints page 2 and pages 6 through 10

  • oshirowanen
    oshirowanen about 10 years
    According to the link I posted, Pages also exists, which should allow me to type in 2, 6-10?
  • OMGtechy
    OMGtechy about 10 years
    Does it work if you try it this way though? Try changing Pages to Range too.
  • oshirowanen
    oshirowanen about 10 years
    Yes, the options From and To work fine, but that will only allow me to print out a sequence, i.e. pages 2 to 5. I want more control, i.e. print pages 2 and 6 to 10.
  • OMGtechy
    OMGtechy about 10 years
    Try changing Copies:=2 to Copies:="2"
  • OMGtechy
    OMGtechy about 10 years
    Also, try swapping Copies and Pages around (in terms of order).
  • oshirowanen
    oshirowanen about 10 years
    Just tried all those suggestions, and it made no difference, each time, it printed all 10 pages twice.
  • oshirowanen
    oshirowanen about 10 years
    Found the solution. Thanks for the help.