Set default printer for excel

Unexpc

Active Member
Joined
Nov 12, 2020
Messages
307
Office Version
  1. 2019
Platform
  1. Windows
Hi guys

there is a option or macro i choose one printer for default?(beacuse i change printer in multiple app and when i change printer, in the excel changed printer, i want choose a default printer just for excel)
 

Attachments

  • Screenshot 2020-11-14 171627.jpg
    Screenshot 2020-11-14 171627.jpg
    63.5 KB · Views: 8

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Dossfm0q

Banned User
Joined
Mar 9, 2009
Messages
570
Office Version
  1. 2019
Platform
  1. Windows
VBA Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Cancel = True
    Dim DefaultPrinter As String
    Dim Tempraryprinter As String

    Tempraryprinter = "Name your Printer" ' <<<<<<Or others like "Microsoft Print to PDF"

    DefaultPrinter = Application.ActivePrinter
    ActiveSheet.PrintOut Preview:=False, ActivePrinter:=Tempraryprinter, PrintToFile:=True, PrToFileName:=PSFileName
    Cancel = False
    Application.ActivePrinter = DefaultPrinter

End Sub

P.gif
 

Attachments

  • Printer.png
    Printer.png
    51.8 KB · Views: 7

Unexpc

Active Member
Joined
Nov 12, 2020
Messages
307
Office Version
  1. 2019
Platform
  1. Windows
VBA Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Cancel = True
    Dim DefaultPrinter As String
    Dim Tempraryprinter As String

    Tempraryprinter = "Name your Printer" ' <<<<<<Or others like "Microsoft Print to PDF"

    DefaultPrinter = Application.ActivePrinter
    ActiveSheet.PrintOut Preview:=False, ActivePrinter:=Tempraryprinter, PrintToFile:=True, PrToFileName:=PSFileName
    Cancel = False
    Application.ActivePrinter = DefaultPrinter

End Sub

View attachment 26075
Thanks man but i have a problem, when i select quick print and i print, it shows again save output as...
What am i do? (I tested microsoft print to pdf that is good and i set it default printer)
 

Dossfm0q

Banned User
Joined
Mar 9, 2009
Messages
570
Office Version
  1. 2019
Platform
  1. Windows
try
VBA Code:
Private Sub Workbook_Open()
    Dim DefaultPrinter As String
    Dim Tempraryprinter As String

    Tempraryprinter = "Microsoft Print to PDF" '

   Application.ActivePrinter = Tempraryprinter & " on Ne01:"
    

End Sub
 
Solution

Unexpc

Active Member
Joined
Nov 12, 2020
Messages
307
Office Version
  1. 2019
Platform
  1. Windows

ADVERTISEMENT

try
VBA Code:
Private Sub Workbook_Open()
    Dim DefaultPrinter As String
    Dim Tempraryprinter As String

    Tempraryprinter = "Microsoft Print to PDF" '

   Application.ActivePrinter = Tempraryprinter & " on Ne01:"
   

End Sub
Yeah thats work, THANKS
 

Dossfm0q

Banned User
Joined
Mar 9, 2009
Messages
570
Office Version
  1. 2019
Platform
  1. Windows
You are welcome
Thank you for Feedback
 

Unexpc

Active Member
Joined
Nov 12, 2020
Messages
307
Office Version
  1. 2019
Platform
  1. Windows
You are welcome
Thank you for Feedback
Hi again
i have recently receive an error for color line
VBA Code:
Private Sub Workbook_Open()
    Dim DefaultPrinter As String
    Dim Tempraryprinter As String


    Tempraryprinter = "Microsoft Print to PDF" '


[COLOR=rgb(226, 80, 65)]   Application.ActivePrinter = Tempraryprinter & " on Ne01:"[/COLOR]
   


End Sub
this may been this problem from another code in this workbook codes?
 

Watch MrExcel Video

Forum statistics

Threads
1,129,450
Messages
5,636,337
Members
416,914
Latest member
DWC199

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
Top