damonj
08-07-2016, 07:19 PM
Hi Everyone, looking for some assistance with a Word Print Macro.
We have a specific requirement to print all the pages except the last page of a document to one tray and the last page to another tray.
I have successfully worked in some code to handle printing the last page of a document, however I'm unsure how to specify everything in a document but not the last page. Can anyone help? My current macro is printing all the pages including the last, then printing the last again to a different tray. This isn't ideal as you end up with the last page printed twice.
Here is what I have so far:
Dim strTempPrinterName As String
strTempPrinterName = "\\myserver\myprinterqueue"
strTempPrinterName = GetPrinter(strTempPrinterName)
With Dialogs(wdDialogFilePrintSetup)
.printer = strTempPrinterName
.DoNotSetAsSysDefault = True
.Execute
End With
With ActiveDocument.PageSetup
.FirstPageTray = 260
.OtherPagesTray = 260
End With
'Print Entire Document to Plain Buff Paper
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
With ActiveDocument.PageSetup
.FirstPageTray = 261
.OtherPagesTray = 261
End With
'Print Last Page to Printed Buff Paper
Selection.EndKey unit:=wdStory
Application.PrintOut FileName:="", _
Range:=wdPrintCurrentPage
With ActiveDocument.PageSetup
.FirstPageTray = 262
.OtherPagesTray = 262
End With
Thanks Damon
We have a specific requirement to print all the pages except the last page of a document to one tray and the last page to another tray.
I have successfully worked in some code to handle printing the last page of a document, however I'm unsure how to specify everything in a document but not the last page. Can anyone help? My current macro is printing all the pages including the last, then printing the last again to a different tray. This isn't ideal as you end up with the last page printed twice.
Here is what I have so far:
Dim strTempPrinterName As String
strTempPrinterName = "\\myserver\myprinterqueue"
strTempPrinterName = GetPrinter(strTempPrinterName)
With Dialogs(wdDialogFilePrintSetup)
.printer = strTempPrinterName
.DoNotSetAsSysDefault = True
.Execute
End With
With ActiveDocument.PageSetup
.FirstPageTray = 260
.OtherPagesTray = 260
End With
'Print Entire Document to Plain Buff Paper
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
With ActiveDocument.PageSetup
.FirstPageTray = 261
.OtherPagesTray = 261
End With
'Print Last Page to Printed Buff Paper
Selection.EndKey unit:=wdStory
Application.PrintOut FileName:="", _
Range:=wdPrintCurrentPage
With ActiveDocument.PageSetup
.FirstPageTray = 262
.OtherPagesTray = 262
End With
Thanks Damon