Specify Printer Using Code in a Macro

P

panamabiology

Hi,

I have a two almost identical macros that open reports in sequence. The
only difference right now is that one is using the PrintOut Action to print
these reports to my default printer. I need the other Macro to print these
same reports to a different printer, in my case Adobe PDF. Can I do this
using code? I don't want to have to manually change the default printer of
each individual report when I need to print them to PDF. I am using Access
2000.

Thanks for any help!
April :)
 
A

Albert D. Kallal

In access 2002 and later, there is a built in printer object, and it lets
you switch the printer with ease.

You can use:

Set Application.Printer = Application.Printers("HP LaserJet Series II")

So, to save/switch, you can use:

dim strDefaultPrinter as string

get current default printer.
strDefaultPrinter = Application.Printer.DeviceName

switch to printer of your choice:

Set Application.Printer = Application.Printers("HP LaserJet Series II")

do whatever.

Swtich back.

Set Application.Printer = Application.Printers(strDefaultPrinter)


If you are using a earlier versions, then you can use my lightweight printer
switch code here:

http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html

While the above code can switch to the pdf printer...you still going to have
to type in a file name for the pdf doc. If you use Stephens solution, then
you don't have to switch printers, nor do you have to even install the adobe
software. You can find his example here:
http://www.lebans.com/reporttopdf.htm
 
P

panamabiology

Thank you for such a prompt response! This works wonderfully for my
application. I have incorporated your form onto mine where the command
button that activates my macro is. Now I only need one macro!

April :)
 

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