Excel changing Default Printer

B

Brad

Alright, the issue I am having is my macro is changing the Default Printer to
my Color Printer. now the macro is supposed to change to my color printer and
print sheets, which it does, but it is changing my Default Printer for all
programs. Thanks for any help.

Sub Finalize()
'
' Finalize Macro
' Macro recorded 12/22/2004 by Psion Teklogix
'

'
Sheets("Products").Select
Range("C11").Select
ActiveCell.FormulaR1C1 = "N"
Range("C12").Select
Sheets("Agreement").Select
Dim ans As String
ans = InputBox("Please Enter Contract #", "Contract #",
Sheets("Agreement").Cells(8, 12).Value)
If ans = "" Then
Exit Sub
Else
With Worksheets("Agreement")
Cells(8, 12) = (ans)
End With
Application.ScreenUpdating = False
On Error Resume Next
Application.ActivePrinter = "HP Color LaserJet P_30 on Ne01:"
If Err.Number = 1004 Then
Application.ActivePrinter = "HP Color LaserJet P_30 on Ne02:"
Err.Clear
End If
Sheets("Letter").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Cover").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Agreement").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Dim WD As Object
Set WD = CreateObject("Word.Application")
WD.Documents.Open ("G:\CONTRACT\Contract Terms\macro\2005
t&cscontract.doc")
WD.ActivePrinter = Application.ActivePrinter
WD.ActiveDocument.PrintOut Background:=False
WD.Application.Quit SaveChanges:=wdDoNotSaveChanges
Set WD = Nothing
Sheets("Agreement").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Cover").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Agreement").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Application.ScreenUpdating = True
End If
End Sub
 
S

Sharad Naik

Before changing the default printer:

Dim oldDefPrinter As String
oldDefPrinter = Application.ActivePrinter

Then change the printer in code.
Take Print Out,

When done do
Application.ActivePrinter = oldDefPrinter

Sharad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top