Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    May 2002
    Location
    Melbourne, Australia
    Posts
    269
    Thanks
    32
    Thanked 0 Times in 0 Posts

    Set paper bins upon opening any document (Word 2003)

    I have two problems I would be grateful for some help with:

    1. I would like to set the paper bin to 'AutoSelect' on every new and existing document I open.

    I created a macro for this purpose, as follows:

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

    The macro works fine on any new document, but when I try and run it on an existing document, it crashes with the following error:

    Run-time error '4608'
    Value out of range

    2. Ideally, I would like this routine to be in an AutoExec macro in my Normal template, but I have been forced to assign a button or keyboard shortcut to it, as Word complains that it can't execute the macro as no document is yet open.

    I would be very grateful for some help.

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

    Re: Set paper bins upon opening any document (Word 2003)

    I don't understand why this code should cause an error on existing documents, it works without problems when I try it. I tested both on existing documents set to use the default bin and on existing documents set to use other bins.

    You should *not* use AutoExec for this - AutoExec is run once when Word is started, it is not run when a document is created or opened. Put the code in macros named AutoNew and AutoOpen instead:

    Sub AutoNew()
    With ActiveDocument.PageSetup
    .FirstPageTray = wdPrinterDefaultBin
    .OtherPagesTray = wdPrinterDefaultBin
    End With
    End Sub

    Sub AutoOpen()
    With ActiveDocument.PageSetup
    .FirstPageTray = wdPrinterDefaultBin
    .OtherPagesTray = wdPrinterDefaultBin
    End With
    End Sub

  3. #3
    3 Star Lounger
    Join Date
    May 2002
    Location
    Melbourne, Australia
    Posts
    269
    Thanks
    32
    Thanked 0 Times in 0 Posts

    Re: Set paper bins upon opening any document (Word 2003)

    Thank you for the prompt response (as usual) Hans. I'm grateful for your help on the AutoNew and AutoOpen (I didn't remember these special macro types).

    Unfortunately, I do get that Run time error I listed above when I try and apply the macro to a document I have opened, but not when Word opens a blank document. Accordingly, I would be grateful if you could advise me on how to track down the cause of that error.

    Thank you

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

    Re: Set paper bins upon opening any document (Word 2003)

    Some printers use non-standard numbers for their bins, so the pre-defined constants such as wdPrinterDefaultBin do not always work. You could try the following:
    - Open an existing document.
    - Select Tools | Macros | Record New Macro...
    - Click OK.
    - Select File | Page Setup...
    - Activate the Paper tab.
    - Select the default tray for both first page and other pages.
    - Click OK.
    - Stop the macro recorder.
    - View the code of the recorded macro.
    - There will be a lot of extra code, but there should be lines in there setting .FirstPageTray and .OtherPagesTray.
    Does that give a clue?

  5. #5
    3 Star Lounger
    Join Date
    May 2002
    Location
    Melbourne, Australia
    Posts
    269
    Thanks
    32
    Thanked 0 Times in 0 Posts

    Re: Set paper bins upon opening any document (Word 2003)

    Hans, the reason I need to do this, is because I have a new printer and corresponding printer driver. I also have stacks of old documents, some of which have paper bins/manual feed set in them.

    I have observed that any macros I have created to select the paper bin are over-ridden by these specific paper bin settings in the documents. Unless these bin settings are changed to 'Default/AutoSelect', the macros are by-passed when selecting the paper bins.

    I have checked the code the printer generates, as you suggested, and they are the correct codes I am trying to use.

    What else could generate that specific error:

    Run-time error '4608'
    Value out of range

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

    Re: Set paper bins upon opening any document (Word 2003)

    Does this version work better? It loops through all sections of a document.

    Sub SetTrays()
    Dim sec As Section
    For Each sec In ActiveDocument.Sections
    With sec.PageSetup
    .FirstPageTray = wdPrinterDefaultBin
    .OtherPagesTray = wdPrinterDefaultBin
    End With
    Next sec
    End Sub

    Sub AutoNew()
    Call SetTrays
    End Sub

    Sub AutoOpen()
    Call SetTrays
    End Sub

  7. #7
    3 Star Lounger
    Join Date
    May 2002
    Location
    Melbourne, Australia
    Posts
    269
    Thanks
    32
    Thanked 0 Times in 0 Posts

    Re: Set paper bins upon opening any document (Word 2003)

    Hans you are wonderful (as always)!

    Whilst applying the paper tray selection to the whole document did not work, looping through all the sections did the trick.

Posting Permissions

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