Macro to select default printer

manc

Active Member
Joined
Feb 26, 2010
Messages
340
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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,217,681
Messages
6,137,951
Members
450,100
Latest member
mscetr

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