bamaisgreat
Well-known Member
- Joined
- Jan 23, 2012
- Messages
- 826
- Office Version
- 365
- Platform
- Windows
I am trying to make this macro print do to a specified printer. I recently found some code on the forum to have it choose the printer I need but I have it at the bottom of this code and I think it needs to be at the top because I need to choose the paper size and keep the other settings. It prints to 2 printers when I run it and only need it to the specified. Thanks Guys for all the help.
Code:
Dim newFileName As String
Dim appendText As String
.Unprotect Password:="1288"
With .Range("J24").Interior
.Pattern = xlSolid
.PatternColorIndex = 1
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
appendText = "-FINAL"
.Range("J24").FormulaR1C1 = appendText
Range("A1:U23").Select
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = "$A$1:$U$23"
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = "&Z&F&F&D&T"
.LeftMargin = Application.InchesToPoints(1)
.RightMargin = Application.InchesToPoints(0.45)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = False
.PrintQuality = 300
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaper11x17
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = True
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = False
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Application.PrintCommunication = True
''Application.Dialogs(xlDialogPrinterSetup).Show
ActiveSheet.PageSetup.PrintArea = "$A$1:$U$23"
'this works great for selecting printer its printing to the specified and the default needs tweaked'
'Const MyPrinter As String = "GSI Purchasing on Ne02:"
'sCurrentPrinter = Application.ActivePrinter
'Application.ActivePrinter = MyPrinter
'ActiveSheet.PrintOut '
'Application.ActivePrinter = sCurrentPrinter
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
.UsedRange.Locked = True
.Protect Password:="1288", DrawingObjects:=True, Contents:=True, Scenarios:=True
End With
With ActiveWorkbook
oldFileName = .FullName
newFileName = Left(.FullName, InStrRev(.FullName, ".xls") - 1) _
& appendText
.SaveAs Filename:=newFileName
End With
Kill oldFileName
End Sub