Print certain pages only

╄→гoц情女王★ 提交于 2019-12-20 02:32:36

问题


SOLUTION:

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

ORIGINAL QUESTION:

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


回答1:


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

For example:

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



回答2:


Alternative solution from the website

expression .PrintOut(Background, Append, Range, OutputFileName, From, To, Item, Copies, Pages, PageType, PrintToFile, Collate, FileName, ActivePrinterMacGX, ManualDuplexPrint, PrintZoomColumn, PrintZoomRow, PrintZoomPaperWidth, PrintZoomPaperHeight

You can use From:="2", To:="5".



来源:https://stackoverflow.com/questions/22661732/print-certain-pages-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!