Code for Printer Setup

J

Joseph

I know that this has been asked a million times before. And the title is
always different, so the posibilty of finding the correct answer is probably
very low. But has there been any updates in the way that a printer setup can
be controlled with VBA or Macro coding?
The reports in my databases switch from portrait to landscape, plus my
databases are networked, with different printers. And with the myraid of
printers out there, I do not want to have code for every single different
printer type out there.
I have just upgraded to Office2007 and am in the process of converting over
the databases. Before, I would get calls about why the reports were coming
out different (portrait/landscape) and I could not give a good enough answer
nor could I find a resolution to the problem other than coding for each
individual printer in the company.
Any answers would be helpful since I am about to purchase new printers.
 
A

Allen Browne

Okay, you are asking how you can programmatically assign a printer to a
report at runtime, and set its orientation.

Since Access 2002, Access has a Printer object. Before you OpenReport, you
can assign it to one of the Printers available on the user's machine, and
the report will go to that printer. Then you need to set the Printer to
Nothing again; otherwise all their reports go to that printer (rather than
their default.)

If you want that to persist, you can store the info in a table, or create a
custom property for the report so it emembers to send that report to that
printer. There's a downloadable example of how to do that here:
Printer Selection Utility - Users assign printers to reports
at:
http://allenbrowne.com/AppPrintMgt.html

You can also set the orientation and margins programmatically once the
report is open in preview. See the SetMarginsAndOrientation() function at
the end of this page:
http://allenbrowne.com/AppRelReportCode.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top