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:)
 

Some videos you may like

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

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
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,907
Messages
5,514,086
Members
408,983
Latest member
mlee13

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top