Microsoft Office Tutorials and References
In Depth Information
Note You should have an error-handling routine in place to inform the user if the workbook
fails to print. If possible, you should also write a routine to print the workbook on another
printer and, in any case, inform the user on which printer the procedure printed the workbook.
Table 7-5 lists and describes the parameters available for use with the PrintOut method. The
settings and descriptions are straightforward, with one exception. When you set the Preview
parameter to Tr ue , Excel displays the workbook in Print Preview mode, within which the
user must click the Print button to begin printing.
Table 7-5. The Parameters of the PrintOut Method
An expression that refers to a workbook, a
worksheet, a chart, an object, or a cell range.
The number of the page at which to start printing. If
this argument is omitted, printing starts at the
The number of the last page to print. If this argument
is omitted, printing ends with the last page.
The number of copies to print. If this argument is
omitted, one copy is printed.
True to have Excel invoke print preview before
printing the object. False (or omitted) to print the
Sets the name of the active printer.
True to print to a file. If PrToFileName isn’t specified,
Excel prompts the user to enter the name of the
True to collate multiple copies.
If PrintToFile is set to True , this argument specifies
the name of the file you want to print to.
If you want to take a user directly to Print Preview, you can do so using the PrintPreview
method. The PrintPreview method, which also applies to sheets, charts, objects, and cell
ranges, has a single parameter: EnableChanges . When the EnableChanges parameter is set to
Tr ue (the default), the user is able to change the workbook’s page setup and margin settings
before printing. When EnableChanges is set to False , the Page Setup and Margins buttons are
disabled, but the user can still choose whether to print (by clicking the Print button) or not
(by clicking the Close button).