Macro to select default printer

manc

Active Member
Joined
Feb 26, 2010
Messages
335
Dear Demigods

I have a macro attached to a button that converts to PDF and emails the sheet automatically - Button A for example purposes.

I then have another button, which is the print button - Button B.

If click I click Button A first, then click Button B, it prints as PDF.

I need a bit of code that will change Button B back to the default printer being used, before printing out without prompts.


Hope that makes sense
Thanks for your time
Regards
manc:)
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Just assign the value of the ActivePrinter to a variable and change back to it when done.

Code:
    Dim strPrinter As String
    strPrinter = Application.ActivePrinter
'   code
    Application.ActivePrinter = strPrinter
 

manc

Active Member
Joined
Feb 26, 2010
Messages
335
Thanks for your suggestion Andrew

This is my code with the help of yours, or if you like, here is your code with my line added!


Sub Print_Sheet()
Dim strPrinter As String

strPrinter = Application.ActivePrinter
ActiveSheet.PrintOut
Application.ActivePrinter = strPrinter

End Sub


Still prints off as PDF.
What am I not doing?

Regards
manc
 

manc

Active Member
Joined
Feb 26, 2010
Messages
335
Re: Macro to select default printer (solved)

Thanks Andrew

I misunderstood what what happening.

I have added your code to the PDF macro, which makes sense now.

All works well. PDF prints as PDF, Printer prints to printer.

Thanks for your help
Regards
manc
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,920
Messages
5,834,375
Members
430,282
Latest member
MeredithD26

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