VBA to Print Labels but Issues Selecting Printer

4starpur

New Member
Joined
Oct 23, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi,

Let me first say I have a rudimentary knowledge of VBA at best, but I'm really hoping someone can help. We have an old script that was written for warehouse employees to print labels for orders. The issue is that the script will randomly change to other printers so labels arent going to the label makers and are printing on the regular printers. Sometimes just changing the default printer in windows settings will fix it for a few days. We have tried changing the active printers in the code but it will still send it to the wrong printer. I changed the printer name below just in case.

Again, I didnt write this so I'm sure there are better ways to do this but this works for what we need. I'm just looking for any obvious issues that may be causing it to occasionally change/fail.

Thanks for any help!


Here is the VBA:

 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
VBA Code:
    Application.Dialogs(xlDialogPrinterSetup).Show
    sCurrentPrinter = Application.ActivePrinter
...


then change

Sheets("Label").PrintOut Copies:=1, ActivePrinter:="PRINTER XYZ"
to
Sheets("Label").PrintOut Copies:=1, ActivePrinter:=sCurrentPrinter
 
Upvote 0

Forum statistics

Threads
1,226,461
Messages
6,191,170
Members
453,644
Latest member
karlpravin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top