Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Feb 2002
    Location
    Ecosse, Scotland
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Printing Macro in Word (Word 2002 SP2)

    I wonder if someone can offer some advice. We recently moved from Word 97 to Word 2002. We have Global Add-in Templates set up to help us with our printing. These consist of a simple userform which allows people to put in how many copies they want of a particular page from a particular bin. The userform then executes a small piece of code which chooses the paper bin and prints out the number of copies which the user typed in the form. This worked beautifully until we moved to Word 2002 (which we are using with Citrix Metaframe and Windows Server 2003). An example of the piece of code is ...

    If frmPrintDocC.txtcontno.Value <> 0 Then
    ActiveDocument.PageSetup.FirstPageTray = 259
    ActiveDocument.PageSetup.OtherPagesTray = 259
    Options.PrintHiddenText = False
    ActiveDocument.PrintOut Copies:=frmPrintDocC.txtcontno.Value
    End If

    ... where txtcontno is the box the user completes with the number of copies. We are having a situation where we are getting "Error 4608 - Value Out of Range" errors. The Debug is always sitting on the "ActiveDocument.PageSetup.FirstPageTray = 259" line. I am really struggling with this one and at the moment I am having to tell my users to select the paper bin manually and print manually which isn't going down too well!!

    Any help or advice would be appreciated.

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

    Re: Printing Macro in Word (Word 2002 SP2)

    Try replacing the value 259 by one of the symbolic wdPaperTray constants. I would guess that you need wdPrinterMiddleBin. Look up wdPaperTray in the Object Browser for other possible values.

  3. #3
    Star Lounger
    Join Date
    Feb 2002
    Location
    Ecosse, Scotland
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing Macro in Word (Word 2002 SP2)

    I tried that Hans but the HP 4200 driver I am using on the printer then takes everything from its default bin. It will only take from the other bins if they are set using the HP number. Thanks anyway.

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

    Re: Printing Macro in Word (Word 2002 SP2)

    Here is a workaround I found in the newsgroups:

    Define a new printer in the Printers control panel. It should point to the same physical HP 4200, but you should explicitly set the bin to print from. On my system, it would be: right click the printer in the Printers control, select Printing Preferences..., activate the Paper/Quality tab, and select the bin in Paper Source.

    The printing code could look like this:

    ' Variable to store printer name
    Dim strAP As String
    If frmPrintDocC.txtcontno.Value <> 0 Then
    ' Store name of current printer
    strAP = ActivePrinter
    ' Set printer to dedicated version
    ActivePrinter = "NameOfNewPrinter" ' fill in actual name here
    ' Set options and print
    Options.PrintHiddenText = False
    ActiveDocument.PrintOut Copies:=frmPrintDocC.txtcontno.Value
    ' Restore original printer
    ActivePrinter = strAP
    End If

  5. #5
    Star Lounger
    Join Date
    Feb 2002
    Location
    Ecosse, Scotland
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing Macro in Word (Word 2002 SP2)

    Hans, I am not sure that i will be able to follow your advice on this one. The printers we use are autocreated in Citrix so the users don't create the printers themselves. I have, however, taken a note of your code and will try and come up with something else. Thanks very much for your time.

  6. #6
    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: Printing Macro in Word (Word 2002 SP2)

    If you record a macro of setting the paper trays in your new environment, does it give you new valid tray numbers? It's a hassle to have to code different versions of the paper tray assignments, but it's so much simpler than generating new printers on the fly...

Posting Permissions

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