Results 1 to 11 of 11
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print Macro (2000/2/3)

    <P ID="edit" class=small>(Edited by kemorr on 26-Aug-08 09:57. )</P>Hi

    I am using a macro to print documents first page on headed the rest on plain, there is more than one letter per file. I am using an input box to get the print range and next page sections to identify the first page for the headed paper.

    I seem to be having some compatiblity issues. I am using Word 2003 and this is were the macro was tested, other users are using word 2000 and word 2002

    Here is the problem part of the code:

    ' Set the printer tray to use, adjust as required
    With ActiveDocument.PageSetup
    .FirstPageTray = 2
    .OtherPagesTray = 1
    End With

    On older versions .FirstPageTray = 2 and .OtherPagesTray = 1 does not work it makes no difference if the numbers are in quotes ("2" and "1"). On removing the 2 and = when I retype = I get some options like wdPrintMidTray or something like that.

    With the numbers I get an error 'out of range' with the wdPrint????? I get type mismatch

    Please help

    Kevin

    Just thought I would add that on an older code we used .DefaultTray = "Tray 2" however "Tray 2" does not work with .FirstPageTray and .OtherPagesTray

    Thanks
    Regards
    Gerbil (AKA Kevin)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print Macro (2000/2/3)

    Word VBA provides a series of numbers for trays, such as wdPrinterUpperBin = 1 and wdPrinterLowerBin = 2.
    However, some printers, notably HP Laser Printers, use different numbers for their trays, such as 256 and 257.
    In other words, the code depends on the printer used. If users have different printers, there is no universal solution for this.

  3. #3
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Macro (2000/2/3)

    Thanks Hans,

    The people using it all print from the same printer/model of printer. However I do not, so that would explain why it works for me.

    They are using HP LAN Laserprinters.

    How can I find out the tray number for these printers?

    Thank

    Kevin
    Regards
    Gerbil (AKA Kevin)

  4. #4
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Macro (2000/2/3)

    Hi,

    I have found that it only happens on certain documents. Fore example

    I can start a new document (blank) type as many letters as I want using next page section breaks between them and the macro works fine.
    I can open some older letters again macro works fine
    But... On som older letters I get the 'out of range' error I mentioned above

    Could this be a setting within the documents if so any ideas as to what.

    Many thanks
    Regards
    Gerbil (AKA Kevin)

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print Macro (2000/2/3)

    You can record a macro of setting the first page tray and other page tray and see which numbers are recorded.

  6. #6
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Macro (2000/2/3)

    Thanks Hans

    Recording the Macro doesn't seem to record the tray change.

    However I have found its only with certain documents, for example

    when I open a file on my computer using my printer the code still falls over on the same thing, but another file will be fine.

    It must be something todo with the properties of the document.

    If I copy the entire document (the one that does not print) and paste into a blank document I get the same problems.

    Any ideas as to what could cause this on some but not all files

    Thanks
    Regards
    Gerbil (AKA Kevin)

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print Macro (2000/2/3)

    You should record the following:

    - Select File | Page Setup...
    - Activate the Paper tab.
    - Select the appropriate trays.
    - Click OK.

    The generated code will include much more than you need here, but there should be lines resembling the following:

    .FirstPageTray = ...
    .OtherPagesTray = ...

  8. #8
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Macro (2000/2/3)

    Thanks Hans

    It shows wdPrinterLowerBin and wdPrinterLargeCapacityBin

    However, this did not solve the problems. There are still .doc files (although not many) that will not print with this macro, they print fine using the manual method. The thing is its not all files only some.

    Thanks

    Kevin
    Regards
    Gerbil (AKA Kevin)

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print Macro (2000/2/3)

    I'm afraid I have no explanation or solution for you. Sorry.

  10. #10
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Macro (2000/2/3)

    Thanks Hans

    Just incase it makes any difference with you or other loungers the exact error is

    Run-time error '4608: Value out of range error

    And if I comment out the following lines the rest is fine

    'With ActiveDocument.PageSetup
    ' .FirstPageTray = 2
    ' .OtherPagesTray = 3
    'End With

    I have tried setting the margins etc for the wholes document to match one that does work but still no luck.

    Many thanks
    Regards
    Gerbil (AKA Kevin)

  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: Print Macro (2000/2/3)

    <hr>If I copy the entire document (the one that does not print) and paste into a blank document I get the same problems.<hr>
    You can think of page setup information as being stored in the section breaks. The last paragraph mark in the document contains the equivalent information for that final section. To avoid carrying over problematic tray settings, do not copy over the section breaks.

Posting Permissions

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