Results 1 to 6 of 6

Thread: [RESOLVED] VBA Word - Tray Selection

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2008
    Location
    Kent, England
    Posts
    713

    Resolved [RESOLVED] VBA Word - Tray Selection

    Hi all, I am currently underway developing a macro, also in another thread in this board, I have managed to get it to print, however im having problems with tray selection.

    Code:
    If cboSelectPrinterModel = "HP 4000/4050" And optSingleLetter = True Then
    Application.ScreenUpdating = False
    With ActiveDocument.PageSetup
    Selection.GoTo what:=wdGoToSection, which:=GoToFirst, Count:=1, name:=""
    .FirstPageTray = 260
    .OtherPagesTray = 259
    .SectionStart = wdSectionContinuous
    End With
    Application.PrintOut Background:=True, Item:=wdPrintDocumentContent, Copies:=txtCopies.Text
     Application.ScreenUpdating = True
     Unload Me
    This code should select the First Page Tray (on a HP Laserjet 4000 to be Tray two (the first actual "Bin Tray"), and Other Pages should Be Printed from the second bin (tray three!), because of the printers that we use, we have to use the Tray ID's as opposed to wdPrinterLowerBin etc.

    Can anyone suggest why no matter what this does, it always prints to the same darned tray (tray three)

    A few points to consider:

    1) The Printer is defaulted to automatically select tray, I have manually set it to print from tray 1 and tray 2 individually, but it still makes no difference!
    2)this code is based under the print button, by which point the printer has been defined, and hopefully, the printer settings (duplex etc) will have been put into place!
    3) I have tried this by LPT1 connection and ethernet connection, I can see no reason for this to actually be a corruption of data on transfer!
    4) The Coding is behind options and is non ammendable by those who use the macro. So if a certain option is chosen then the first page is printed from tray two and all others are printed through tray three, another option may mean that all pages are printed from tray three.

    Any help will be greatly appreciated!

    James

  2. #2
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,657

    Re: VBA Word - Tray Selection

    Are you sure you are using the correct values - 259 & 260 for the Trays ?? and how did you come about these values ?

    The reason I say this is I have had to create Print toolbars in the past and at home I have a macro somewhere that will return all the available tray options for the default printer.

    Often the macro would return quite a few numbers, more then the actual number of trays, and actually some of them related to finishing options as well as a specific tray.

    In the end I had to run the macro, return all the possible numbers and test print to all of them until I got the numbers for the trays I wanted.

    I am at work at the moment but when I get home I could dig out the macro for you if would help you ?

    The only other issues I came across where to do with the printer driver itself. Do you have the exact printer driver installed for you printer rather than a generic one ? I have come across that and it causes issues.

    Finally the only other issue I came across was in large multi tray printers where you could add extra trays, and these extra trays had not been added on the printer Properties page. However it sounds like this is Not your issue !!
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2008
    Location
    Kent, England
    Posts
    713

    Re: VBA Word - Tray Selection

    I have all the actual drivers installed, and I had a program that was written a while back that does exactly that, it does return the drivers tray values, we have been using these values on our other print macros and they all work ok on the old macros, but not now when I could really do with it! so I have the values just not the co-operation of the printer, or VBAW!

    However if you dont mind I will give it a try, and make sure all the values returned are the correct ones!

    Hope this makes sense!

    James
    Last edited by JayCR; Sep 17th, 2008 at 09:34 AM.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: VBA Word - Tray Selection

    those values sound perfectly good for a HP printer, mine are
    manual 258
    tray1 259
    tray2 260
    printer auto select 257
    Auto 15

    these work fine from the vb printer object, but i have never tried using in VBA

    i have no tray 3
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2008
    Location
    Kent, England
    Posts
    713

    Re: VBA Word - Tray Selection

    Im hoping someone can help me as this is getting a little out of hand, the printer will not be told what to do

    Code:
    If cboSelectPrinterModel = "HP 4000/4050" And optSingleLetter = True Then
    Application.ScreenUpdating = False
    Selection.GoTo what:=wdGoToSection, which:=GoToFirst, Count:=1, name:=""
    ActiveDocument.PageSetup.FirstPageTray = wdPrinterUpperBin
    ActiveDocument.PageSetup.OtherPagesTray = wdPrinterMiddleBin
    Application.PrintOut Background:=True, Item:=wdPrintDocumentContent, Copies:=txtCopies.Text
     Application.ScreenUpdating = True
     Unload Me
    ActivePrinter = MyDefaultPrinter
    Im sure that many of you will agree, that this should in effect tell the printer the first page comes out of tray 2 and the second and all other pages come from tray 3! but no matter what happens, it just keeps on printing from tray 3, at some point earlier I managed to get it to print from tray three but it no longer works. It wont even let me use the Tray ID numbers.

    Tray2 = 260
    Tray3 = 259

    (Those are the actual tray recognition codes)

    Code:
    If cboSelectPrinterModel = "HP 4000/4050" And optSingleLetter = True Then
    Application.ScreenUpdating = False
    Selection.GoTo what:=wdGoToSection, which:=GoToFirst, Count:=1, name:=""
    ActiveDocument.PageSetup.FirstPageTray = 260
    ActiveDocument.PageSetup.OtherPagesTray = 259
    Application.PrintOut Background:=True, Item:=wdPrintDocumentContent, Copies:=txtCopies.Text
     Application.ScreenUpdating = True
     Unload Me
    ActivePrinter = MyDefaultPrinter
    Neither of the above will allow tray control, I was talking to westconn1 earlier, and it seemed to work, but no longer, has anyone got any ideas!!!!

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2008
    Location
    Kent, England
    Posts
    713

    Re: VBA Word - Tray Selection

    After reviewing the situation, and banging my head repeatedly off the wall, I have found the conclusion that the print macro itself was not to blame and that the values used were correct, however, the printer was faulty, causing all this living hell....

    Thanks To All!

Posting Permissions

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



Click Here to Expand Forum to Full Width