Link to home
Start Free TrialLog in
Avatar of HKFuey
HKFueyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VBA to change default printer

I want to change my default printer, print some labels then change it back.

I found this but it does not work (See error Pic)

     Dim prt As Printer
    ' Get current default printer
    Set prt = Application.Printer
    ' Set default printer
    Application.Printer = Application.Printers(strPrinterName)

Open in new window


Can anyone help?User generated image
SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
HKFuey ,

I use the code you posted to set the applicant print all the time.

The key to the code is how you set the value in strPrinterName.

How are you setting the value for strPrinterName?


TIP:
If the label printer  will not change, set the report to always print to that printer not the default printer..
Avatar of HKFuey

ASKER

Hi Boyd,
Re: How are you setting the value for strPrinterName?

Dim strPrinterName
strPrinterName ="My Printer Name"

I only have 4 reports and 2 label printers, I'm beginning to think the simplest way is to set the printer on the report and just let the user choose which format they want.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HKFuey

ASKER

Thanks for the help.