Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    New Lounger
    Join Date
    Mar 2002
    Location
    Copenhagen, Denmark
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Controlling paper trays (2002/XP)

    Greetings!

    I have converted the templates in a pretty large organisation from Office 95 to Office XP - and they have of course many printers, also many printers of different kind, but all printers are HP - ranging from HP LJ 4Si through HP LJ 4000 to large HP Color LaserJets. I need to ensure that the letter template always prints the first page on letter paper and the rest on blank paper. The rule in the organisation is that letter paper is placed in the lowest papertray and blank paper is in the standard papertray. When setting up a new printer(model) they print a letter to the printer - whatever tray
    the first page is printed from is filled with letter paper and the other tray(s) is filled with blanked paper and this tray is also defined as the standard tray on the printer.

    My problem is that when I set the first page to print from the lowest tray and the rest of the pages to print from the standard tray on any given printer model (say HPLJ4Si), the setting for the first page is reset to Automatic Selection when I shift to print from another printer (say HPLJ4000). This happens no matter what printer I use when defining the tray selection. I can't seem to find the proper way to define this. I know that controlling printers is a hell, but there must be a way to control tray selection across a platform of multiple printer models.

    Any suggestions and ideas are much welcome.

  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Controlling paper trays (2002/XP)

    I don't have Office XP, but this works in W2K, so it should work in XP.

    The first thing you need to do is to read <post#=196505>post 196505</post#> and follow the the steps up to where it says "That's the base code...." and place all the code in your template.

    Now switch to the EventHandler Class module.

    Add the following prcoedure to the class:

    Private Sub objWord_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
    If Doc.AttachedTemplate = "YourTemplate.dot" Then
    With Doc.PageSetup
    .FirstPageTray = wdPrinterLowerBin
    .OtherPagesTray = wdPrinterDefaultBin
    End With
    End If
    End Sub

    What this will do is that everytime the user goes to print the document, the BeforePrint event will fire. If the attached template of the document being printed is your letter template, it will set the First Page and other Page trays to whatever tray you want.

    You may need to play with the constants (wdPrintLowerBin...) to get it printing to the correct bins. If you place the insertion point on .FristPageBin and hit F1, it should pop up the help entry that lists all the predefined constants that you can use.

    This way, your users can select any printer and it should work with no additional work on your part.

    Come back if you have an questions or problems.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  3. #3
    New Lounger
    Join Date
    Mar 2002
    Location
    Copenhagen, Denmark
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Controlling paper trays (2002/XP)

    Hi Bryan

    I have tried your solution and it seems to work fine in XP as well. I do have some problems still though. The BeforePrint event fires when the user chooses File | Print... and the code is therefore executed before the dialog is shown to the user - if the user changes the activeprinter, my code has already executed and the tray selection may be wrong. Do you know any way to execute my code AFTER the user has selected a printer in the Print-dialog and BEFORE the document is actually printed?

    brgds
    Jaspar

  4. #4
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Controlling paper trays (2002/XP)

    Unfortunately, the BeforePrint is the only one print event that I am aware of.

    However, if you create a macro called FilePrint that will hijack File|Print... and CTRL+P and allow you to run your own code of choosing.

    Something like this may work for you

    Sub FilePrint()
    ActiveDocument.PrintOut
    EndSub

    All this will do is print the active document with the default settings. But your BeforePrint code will change the printer and trays and then set it back.

    The user won't get the standard PrintDialog Box, so if they need multiple copies, then they will have to do multiple prints.

    It's not the most elegant solution, but it may work out for you.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Controlling paper trays (2002/XP)

    Would it not be possible to .Display the FilePrint dialog box in your FilePrint routine, then set the tray options and then .Execute, something like this...

    Sub FilePrint()
    MyPrint
    End Sub

    Sub FilePrintDefault()
    MyPrint
    End Sub

    Sub MyPrint()
    With Dialogs(wdDialogFilePrint)
    If .Display = -1 Then
    With ActiveDocument.PageSetup
    .FirstPageTray = wdPrinterLowerBin
    .OtherPagesTray = wdPrinterDefaultBin
    End With
    .Execute
    End If
    End With
    End Sub

    StuartR

  6. #6
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Controlling paper trays (2002/XP)

    Oh sure Stuart, come up with a better solution <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    I can't see why that wouldn't work better than even my original solution.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  7. #7
    New Lounger
    Join Date
    Mar 2002
    Location
    Copenhagen, Denmark
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Controlling paper trays (2002/XP)

    Thanks Stuart,

    I really think your proposed solution will do the trick - it's getting late here in Denmark, but I'll try it tomorrow. And Bryan, thanks to you too for your help - you almost got me off on a completely wrong track <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15>, but I was all mixed up in stupid papertrays and appreciated your help <img src=/S/wink.gif border=0 alt=wink width=15 height=15>.

    brgds
    Jaspar

  8. #8
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Controlling paper trays (2002/XP)

    Stuart, I read your post with great excitement, as I am in the process working out the details of transferring my company from custom dedicated paper towers on ordinary single tray printers, to new big printers with around four trays built-in and using a PS driver - and so far the only way I have found of controlling the trays used is with Postscript codes in the header, which is extremely cumbersome and open to many problems.

    However, when I tried your code, although the PC is definitely using it (I put in a msgbox to check before starting), it just completely ignored the papertray settings! I tried Upper bin, Lower bin, middle bin and default bin on a printer with two trays plus manual feed, and no matter what tray I specified, it always fed from the lower tray unless there was something in the manual tray, in which case it used that.

    I'm using WinNT4 and Word97 with the latest HP postscript drivers for the printer, by the way.

    Is it likely to be something to do with the fact that I'm using a PS driver, do you think? (I hope not, because I don't have any choice on that - it's the only driver that prints our logo graphic to an acceptable standard!).

    Any comments would be gratefully received!
    Beryl M


  9. #9
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Controlling paper trays (2002/XP)

    As an aside, the code I'm using to control the PS driver's trays is the following field code:

    { PRINT p page " grestore matrix currentmatrix
    <</ManualFeed false /MediaPosition 1>> setpagedevice
    setmatrix gsave
    " * MERGEFORMAT }

    Obviously this has to be placed in every template and, for that matter, every existing document in order to work. However, I have the templates and documents set up already using categories (ActiveDocument.BuiltInDocumentProperties(wdProper tyCategory) = "letter", or whatever) and it occurs to me that I could use a macro like yours in the normal.dot to say, effectively "if the category is 'letter', print the first page from here and the rest from here, etc" - if I could work out how to incorporate the above PS code in VBA!

    Do you have any idea where to start?! If it helps, the media position is the tray (although the numbers do not relate in any way to the tray numbers, they seem to have been set arbitrarily!), and the above code basically says 'remember the current settings, change them for this job, return to the original settings'. At least, that's what I understand by it!

    Many thanks!

    PS If you think it more appropriate, I could repost this query on the VBA board ...
    Beryl M


  10. #10
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Controlling paper trays (2002/XP)

    Before you print can you go to pagesetup and see which printer trays are selected for first page and other pages. Then do the same after you print.
    I have tested this code and it appears to work correctly, it certainly changes the page setup. Maybe your postscript is overriding the driver settings?

    Legal settings for the variables are...
    wdPrinterAutomaticSheetFeed
    wdPrinterDefaultBin
    wdPrinterEnvelopeFeed
    wdPrinterFormSource
    wdPrinterLargeCapacityBin
    wdPrinterLargeFormatBin
    wdPrinterLowerBin
    wdPrinterManualEnvelopeFeed
    wdPrinterManualFeed
    wdPrinterMiddleBin
    wdPrinterOnlyBin
    wdPrinterPaperCassette
    wdPrinterSmallFormatBin
    wdPrinterTractorFeed
    wdPrinterUpperBin

    But I suspect you have to choose the correct ones for your selected printer!

    StuartR

  11. #11
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Controlling paper trays (2002/XP)

    I assume you are using one of the more modern versions of Windows. If you inspect Properties for the printer, what does your Device Settings tab look like?
    Attached Images Attached Images

  12. #12
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Controlling paper trays (2002/XP)

    Unfortunately, no, I'm not using one of the more recent versions of Windows (at least, I don't consider NT4 to be one, do you?!). However, the tray options for the printer look quite similar to your screen dump in that it lists the trays, numbered 1 to 3 (on my test printer - it will be four or five on the new ones), 1 being the manual feed, 2 the standard tray and 3 a larger added tray.
    Beryl M


  13. #13
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Controlling paper trays (2002/XP)

    Hi Stuart, yes, I had found that list of constants - the ones I mentioned (upper, lower, middle and default) are the ones I tried yesterday, but I just repeated the experiment, checking the settings before and after as you suggested, and while before it was set to "Default tray (automatically select)", afterwards it had moved to the next option - which is "Automatically select"! I tried several options again and it wouldn't budge.

    Do you think it's worth me trying the 'odd' options, like PrinterTractorFeed and PrinterPaperCassette? I didn't before because it seemed so unlikely, but maybe it's worth trying them ...
    Beryl M


  14. #14
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Controlling paper trays (2002/XP)

    OK, I've tried every single option on that list and it ignores every one! <img src=/S/sigh.gif border=0 alt=sigh width=15 height=15>
    Beryl M


  15. #15
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Controlling paper trays (2002/XP)

    I'm stumped, it worked for me. Can you try a different printer, just to see what happens.

    StuartR

Page 1 of 2 12 LastLast

Posting Permissions

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