Change default printer programatically in AccessXP

  • Thread starter Thread starter Mike
  • Start date Start date
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
 
AccessXP has the Printer Object which you can use to manage the printers.

Check Access VB Help on the Printer Object.
 
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)
 
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)
 
Back
Top