vba 仅打印某些页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22661732/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 02:29:35  来源:igfitidea点击:

Print certain pages only

vbaoffice-2010word-2010

提问by oshirowanen

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.

这将我的 10 页文档打印两次。

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

我现在想使用该pages选项仅指定要打印的某些页面:

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.

我原以为它会打印出第 2 页和第 6 到 10 页两次,即 2,6,7,8,9,10,2,6,7,8,9,10,但它只是将所有 10 页打印了两次。

I am using VBA in Word 2010.

我在 Word 2010 中使用 VBA。

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

页数- 可选 - 变体 - 要打印的页码和页面范围,以逗号分隔。例如,“2, 6-10”打印第 2 页和第 6 到 10 页

采纳答案by oshirowanen

Range:=wdPrintRangeOfPagesneeds to be added along with Pages.

Range:=wdPrintRangeOfPages需要与Pages.

For example:

例如:

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

回答by OMGtechy

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

表达式.PrintOut(Background, Append, Range, OutputFileName, From, To, Item, Copies, Pages, PageType, PrintToFile, Collat​​e, FileName, ActivePrinterMacGX, ManualDuplexPrint, PrintZoomColumn, PrintZoomRow, PrintZoomPaperWidth, PrintZoomPaperHeight

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

您可以使用From:="2", To:="5".