O'Reilly logo

Writing Word Macros, Second Edition by Steven Roman PhD

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Printing-Related Methods

The PrintOut method will print all or part of a document. Its syntax is:

DocumentObject.PrintOut(Background, Append, Range, _
	   OutputFileName, From, To, Item, Copies, Pages, _
	   PageType, PrintToFile, Collate, FileName, _
	   ActivePrinterMacGX, ManualDuplexPrint)

Note that the PrintOut method can also be applied to a Window object to print the contents of the window, or it can be used globally, as in:

	PrintOut "d:\word\letter.doc"

to print the active document. The myriad arguments of the method correspond to the items on the Print dialog box. All of these arguments are optional variants.

In addition to using the PrintOut method in this global way, we frequently want to exercise greater control over printing. The following sections examine some of the ways that you can do that.

Printing to a File

To print to a file, set the following parameters of the PrintOut method:

PrintToFile

Set this to True to print to a file.

OutputFileName

Set this to the full path and name of the output file.

Append

Set this to True to append the document to the output file or False to over-write the contents of the output file.

Restricted Printing

To restrict printing, set the following parameters:

Range

The page range for printing. It can be any one of the constants in the following enum:

Enum WdPrintOutRange
   wdPrintAllDocument = 0
   wdPrintSelection = 1
   wdPrintCurrentPage = 2
   wdPrintFromTo = 3
   wdPrintRangeOfPages = 4
End Enum
From

If Range is wdPrintFromTo, set this to the starting page number. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required