ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   changing and re-setting the default printer (https://www.excelbanter.com/excel-programming/389335-changing-re-setting-default-printer.html)

dd

changing and re-setting the default printer
 
I'm trying to create a menu item based on a macro to print to PDF. The
problem is that after it has printed the default printer remains PDF. I want
to reset the active printer to 5004

I recorded two macros, one to print to pdf and one to reset the printer but
the part "Ne05 seems to vary every day so that the macro doesn't reset my
default printer to 5004.

Application.ActivePrinter = "PDF995 on Ne00:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDF995 on Ne00:", Collate:=True

Application.ActivePrinter = "\\S1103\A5004 on Ne05:"
'ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
' "\\S1103\A5004 on Ne05:", Collate:=True

I notice in Word I can simply use:

Application.ActivePrinter = "PDF995" and
Application.ActivePrinter = "A5004"

But Excel doesn't accept this.

Regards
Dylan
Scotland




NickHK

changing and re-setting the default printer
 
Store the name of the acrtivePrinter before you change it; then reset

dim OldPrinterName as string

OldPrintername =Application.ActivePrinter
'..code
Application.ActivePrinter=OldPrintername

NickHK

"dd" <dd.dd wrote in message
...
I'm trying to create a menu item based on a macro to print to PDF. The
problem is that after it has printed the default printer remains PDF. I

want
to reset the active printer to 5004

I recorded two macros, one to print to pdf and one to reset the printer

but
the part "Ne05 seems to vary every day so that the macro doesn't reset my
default printer to 5004.

Application.ActivePrinter = "PDF995 on Ne00:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDF995 on Ne00:", Collate:=True

Application.ActivePrinter = "\\S1103\A5004 on Ne05:"
'ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
' "\\S1103\A5004 on Ne05:", Collate:=True

I notice in Word I can simply use:

Application.ActivePrinter = "PDF995" and
Application.ActivePrinter = "A5004"

But Excel doesn't accept this.

Regards
Dylan
Scotland






dd

changing and re-setting the default printer
 
Nick

Thank you for solving this problem for me.

Kind regards
Dylan

"NickHK" wrote in message
...
Store the name of the acrtivePrinter before you change it; then reset

dim OldPrinterName as string

OldPrintername =Application.ActivePrinter
'..code
Application.ActivePrinter=OldPrintername

NickHK

"dd" <dd.dd wrote in message
...
I'm trying to create a menu item based on a macro to print to PDF. The
problem is that after it has printed the default printer remains PDF. I

want
to reset the active printer to 5004

I recorded two macros, one to print to pdf and one to reset the printer

but
the part "Ne05 seems to vary every day so that the macro doesn't reset my
default printer to 5004.

Application.ActivePrinter = "PDF995 on Ne00:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDF995 on Ne00:", Collate:=True

Application.ActivePrinter = "\\S1103\A5004 on Ne05:"
'ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
' "\\S1103\A5004 on Ne05:", Collate:=True

I notice in Word I can simply use:

Application.ActivePrinter = "PDF995" and
Application.ActivePrinter = "A5004"

But Excel doesn't accept this.

Regards
Dylan
Scotland








All times are GMT +1. The time now is 06:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com