PDA

View Full Version : Printer command macro via toolbar in word



JamesL
06-26-2006, 10:52 AM
Hello all

I would like to create a macro that prints two copies of a document, one copy from tray one of the printer and the other from tray two from an icon on the toolbar of word. Could somebody please point me in the right direction?

JamesL

mdmackillop
06-26-2006, 11:24 AM
Hi James,
Welcome to VBAX
The simplest way to do this is to record a macro, changing the printer tray in Page Setup and printing for both settings. If you can post the resultant code, we can assist in tidying it up.
Regards
MD

JamesL
06-26-2006, 12:19 PM
MD
Here is my attempt! although I go through the the different trays while recording the macro it just seems to take two coppies from tray two.
Regards
James


Sub Letter()
'
' Letter Macro
' Macro recorded 6/26/2006 by Computer Department
'
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
End Sub

mdmackillop
06-26-2006, 12:35 PM
The trays have to be changed using PaperSource or similar in Page Setup, not the printer software which probably won't record in the VBA macro.
Different printer may have different settings, but give the following a try.


Sub Letter()
'Possible print tray options
'257, 258, 259, 260, 261, wdPrinterLargeCapacityBin
With ActiveDocument.PageSetup
.FirstPageTray = 260
.OtherPagesTray = 260
End With
Application.PrintOut Copies:=1
With ActiveDocument.PageSetup
.FirstPageTray = 259
.OtherPagesTray = 259
End With
Application.PrintOut Copies:=2
End Sub

mdmackillop
07-04-2006, 01:04 AM
:whistle:

fumei
07-04-2006, 08:55 PM
Huh?

mdmackillop
07-05-2006, 12:15 AM
...while waiting a response.

fumei
07-05-2006, 06:07 AM
Ah.