Programmatically Change Printer Options
Problem
You’ve tried using SendKeys to change printing options in the File → Setup Page dialog, but this really isn’t satisfactory. Sometimes it works and sometimes it doesn’t, depending on the circumstances and the printer driver that’s loaded. Is there some way to modify printer options without using SendKeys?
Solution
Windows makes many of the printer driver settings available to applications, including the number of copies, page orientation, and page size. Access 2002 makes it easy to retrieve and modify these values, using the Printer property of forms and reports. This solution focuses on the print settings features of the Printer object and demonstrates how to read and write values in the Printer object.
To be able to modify printer settings for reports or forms in your own applications, follow these steps:
Open the report in either preview or design view. (If you want to make your changes persistent, open the report in design view. If you want to apply changes for just this particular instance, open it in preview mode.)
Modify some of the properties of the Printer object provided by your form or report. For example, the sample form works with a small subset of the available printer-specific properties, using code like this:
DoCmd.OpenReport strReport, View:=acViewPreview With Reports(strReport).Printer Me.txtCopies = .Copies Me.grpOrientation = .Orientation Me.grpPaperSize = .PaperSize End WithWhen you’re done working with the properties, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access