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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
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,214,399
Messages
6,119,279
Members
448,884
Latest member
chuffman431a

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