Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 284286 - Last Review: June 15, 2007 - Revision: 6.2
How to reset changes to the Application.Printer object
This article was previously published under Q284286
Moderate: Requires basic macro, coding, and interoperability
skills.
This article applies to a Microsoft Access database (.accdb and.mdb) and to a
Microsoft Access project (.adp).
SUMMARY
This article shows you how to reset the Application.Printer object to its default settings after you have customized them.
MORE INFORMATION
The following sample code demonstrates how to print the
Catalog report in the Northwind
Sample Database. It changes some of the default printer settings and when the
print job is completed, the code reset the printer to the default settings.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
Note Not all printers and printer drivers support the functionality in
the following sample code.
Note In Microsoft Office Access 2007, you only have to replace the report name "Catalog" with an available report for the sample code..
Private Sub PrintCatalogReport()
Dim rpt As Report
Application.Printer = Application.Printers(0)
DoCmd.OpenReport "Catalog", acViewPreview, , , acHidden
Set rpt = Reports!Catalog
With rpt.Printer
.BottomMargin = 720
.Copies = 2
.Duplex = acPRDPVertical 'Double sided
.PaperBin = acPRBNLargeCapacity
End With
DoCmd.OpenReport "Catalog", acViewNormal
DoCmd.Close acReport, "Catalog", acSaveNo
Set Application.Printer = Nothing
End Sub
When the print job is completed, this code will clear out the current
settings and reset the global
Application.Printer object to the default application printer.
APPLIES TO
- Microsoft Office Access 2007
- Microsoft Office Access 2003
- Microsoft Access 2002 Standard Edition
| kbprogramming kbsettings kbprinters kbreport kbprint kbhowto KB284286 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please