Word Macro for other tray printing

自闭症网瘾萝莉.ら 提交于 2020-07-09 11:34:07

问题


For years our office has been using HP printers and a few Macros in MS Word that add buttons to the toolbar. One prints the job to tray 3 (plain paper), one prints the first page to tray 2 (pre-printed letterhead) and the rest to tray 3, and the last sends the whole job to tray 1 (manual feed for labels etc.).

This has all been pretty straight cut to tweak if the printer changed, but now we have replaced all of those HP printers with Canon printers and are using the UFRII drivers...

The macro sort of works, but not quite. The issue is that previously the tray assignments were set with the tray numbers eg.

Sub Letterhead()
'
' Prints the Letterhead copy of documents (First page LH, balance on Plain)
' Created By Reece on 24/01/2011
'
    With ActiveDocument.PageSetup
        .FirstPageTray = 263
        .OtherPagesTray = 262
    End With

    Application.PrintOut , Range:=wdPrintAllDocument

    With ActiveDocument.PageSetup
        .FirstPageTray = wdPrinterDefaultBin
        .OtherPagesTray = wdPrinterDefaultBin

    End With
End Sub

but now the tray assignments are using what I've got below:

Sub Letterhead()
'
' Prints the Letterhead copy of documents (First page LH, balance on Plain)
' Created By Reece on 08/05/2013
'
    With ActiveDocument.PageSetup
        .FirstPageTray = wdPrinterUpperBin
        .OtherPagesTray = wdPrinterMiddleBin
    End With

    Application.PrintOut , Range:=wdPrintAllDocument

    With ActiveDocument.PageSetup
        .FirstPageTray = wdPrinterDefaultBin
        .OtherPagesTray = wdPrinterDefaultBin

    End With
End Sub

Usually, all I'd have to do to find out the new printer's tray numbers is record the macro by running through the procedue (page layout > change trays > print > change trays back) and taking note of the numbers... but I'm not getting numbers with the new printers.

Can anyone help find what the tray assignment numbers are for Canon LBP6680's?


回答1:


Don't worry, these are Visual Basic constants, which actually are numbers as well. You don't have to buy some commercial product.

In Word, use the Alt-F11 key combo to open the VBA editor. In the editor, use F2 to open Objectenoverzicht (I have a Dutch version of Word, maybe this is called "Object view" or something). Near the top in the right pane are two drop down list boxes. Type one of the constants, say wdPrinterUpperBin, in the lower box and hit the button with the binocular. A pane opens on the right below that lists all possible terms. When you select one of these, the corresponding number is given in a section below the pane.

Kind regards,

Coos




回答2:


The particular tray numbers depend on the printer driver and the printer manufacturer. There is a commercial product that we have used called Tray Selector. Their site is www.trayselector.com. Its not very expensive and I suggest you check it out. We used to use a macro based solution in our law firm until we discovered this small .Net addin which is relatively inexpensive compared to what we now save in wasted paper and toner.

If you really want to find out the tray numbers for particular printers you can even install this product then look in the registry under HKCU/Sofware/TraySelector/Profiles and you'll see what the tray numbers are for the different trays. You can then use the code above.

Hope that helps



来源:https://stackoverflow.com/questions/17158858/word-macro-for-other-tray-printing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!