Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
882 views
in Technique[技术] by (71.8m points)

vba - Print certain pages only

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

For example:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...