+ Reply to Thread
Results 1 to 2 of 2

Excel changing Default Printer

  1. #1
    Brad
    Guest

    Excel changing Default Printer

    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

  2. #2
    Sharad Naik
    Guest

    Re: Excel changing Default Printer

    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
    "Brad" <[email protected]> wrote in message
    news:[email protected]...
    > 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




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1