Change default printer programatically in AccessXP

M

Mike

Hi

Does anyone know how to switch the default printer back and forth between
one installed printer and another in MS-Access 2002 ?

We have some very old code for Access 97 that read and writes to the win.ini
file but I'm not sure its 100% reliable as we have had varying results.

Is there some way of changing the registry to support this or anyother way
of doing this ?

Thanks

Michael
 
V

Van T. Dinh

AccessXP has the Printer Object which you can use to manage the printers.

Check Access VB Help on the Printer Object.
 
D

david epsom dot com dot au

BTW, the reason the old code doesn't work very well is not
because it's Access 97 -- it's because Win2K and WinXP handle
printers and INI files differently than Win 98.

(david)
 
A

Albert D. Kallal

In a2002, you can use:

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 defualt printer.
strDefaultPrinter = Application.Printer.DeviceName

' swtich to printer of your choice:

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

do whatever.

' now Swtich back.

Set Application.Printer = Application.Printers(strDefaultPrinter)
 
M

Mike

Thanks to all - you all confirmed what I had suspected.

Appreciate the guidance on this.

M
 

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