[AccessD] How to Change Default Printer via Access 2007 VBA Code

James Button jamesbutton at blueyonder.co.uk
Wed Mar 5 15:17:15 CST 2014


Google search 
VBA set default printer access
Gets the following as Nº1 link - hoping it will work in 2007 2010 & 2013

HansV MVP replied on April 29, 2012See post history Close  
 
MVP MCC: Content Creator  
You should be able to do something like this:

 Sub SwitchPrinter()
     Dim prt As Printer
     ' Get current default printer
     Set prt = Application.Printer
     ' Set default printer
     Application.Printer = Application.Printers("OtherPrinter")
     ' Print something, e.g.
     DoCmd.PrintOut
     ' Restore original printer
     Set Application.Printer = prt
 End Sub

 
where OtherPrinter is the name of the required printer. To list the names of
available printers, run the following code:

 
Sub ListPrinters()
     Dim prt As Printer
     For Each prt In Printers
         Debug.Print prt.DeviceName
     Next prt
 End Sub

The printer names will be listed in the Immediate window (press Ctrl+G to
activate this window).

JimB

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Brad Marks
Sent: Wednesday, March 05, 2014 9:03 PM
To: Access Developers discussion and problem solving
Subject: [AccessD] How to Change Default Printer via Access 2007 VBA Code

All,

We have a report that needs to be printed on a specific printer (let's
call it Printer-B).

One of our key users has her default printer set to Printer-A.

Is it possible to temporarily change her default printer to Printer-B
for the printing of a specific report and then change the default
printer back to Printer-A after the report is printed?

Thanks,
Brad  

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list