Yes, you can specify which pages are printed from Word VBA.
The VBA Method is "PrintOut". For example:
ActiveDocument.PrintOut
The syntax is:
.PrintOut(Background,
Append, Range, OutputFileName,
From, To, Item, Copies,
Pages, PageType, PrintToFile,
Collate, FileName, ActivePrinterMacGX,
ManualDuplexPrint, PrintZoomColumn,
PrintZoomRow, PrintZoomPaperWidth,
PrintZoomPaperHeight)
You will want to set the Range, From, To and/or the Pages properties as follows:
Range Optional Variant. The page range. Can
be one of the following WdPrintOutRange constants:
wdPrintAllDocument, wdPrintCurrentPage, wdPrintFromTo,
wdPrintRangeOfPages, or wdPrintSelection.
OutputFileName Optional Variant. If
PrintToFile is True, this argument specifies the path and
file name of the output file.
From Optional Variant. The starting page
number when Range is set to wdPrintFromTo.
To Optional Variant. The ending page number
when Range is set to wdPrintFromTo. 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. Hopefully this will get you going.
------------- Michel Korwin-Szymanowski
EXP Systems LLC
|