Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    New Lounger
    Join Date
    Jan 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Printing first page to a different printer? (word 97/20001)

    I am trying to print (batch print if possible) a series of multiple page documents and I want the first page to go to one printer (or tray, ie, for letterhead) and all subsequent pages in that document to go to a different printer/tray (ie, with plain paper).... is that possible?
    Thanks!

  2. #2
    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 first page to a different printer? (word 97/20001)

    There is a huge difference between printer and tray. To print to a different tray, use (or programmatically manipulate) the settings under Page Setup for Paper Source. To print to a different printer, I'd have to research the steps, but if you are in a coding mode, you could look up the ActivePrinter property and see if that allows you to change, as well as to discover, the current printer.

  3. #3
    New Lounger
    Join Date
    Jan 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing first page to a different printer? (word 97/20001)

    which do you think would be easier/better, if either..? it seems like you could define two printers--one defaulting to tray 1, and the other defaulting to tray 2, for instance.... but is it possible (in vb/vbs) to then send just the first page of a document to one and the rest to the other?

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Printing first page to a different printer? (word 97/20001)

    Still unclear what you're trying to do, but by far the easiest way is to follow Jefferson's suggestion to use the Page Setup dialog to sent first page/continuation pages to different trays on the same printer - see attached screen shot.

    Gary
    Attached Images Attached Images

  5. #5
    New Lounger
    Join Date
    Jan 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing first page to a different printer? (word 97/20001)

    right, but let's say i have 15 documents in a given directory, and i want to write a script (say, vbs) to print eahc of them this way....how can you select those paper source selections with vbs?

  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 first page to a different printer? (word 97/20001)

    Does this get you started?
    <pre>With ActiveDocument.Sections(1).PageSetup
    .FirstPageTray = wdPrinterUpperBin
    .OtherPagesTray = wdPrinterLowerBin
    End With
    ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges</pre>

    Note that each section in a document can have its own PageSetup settings. This code updates the first section, and you will have to decide what to do with any other sections the document might have. Might not be an issue for your documents.

    <img src=/w3timages/blueline.gif width=33% height=2><img src=/w3timages/blueline.gif width=33% height=2><img src=/w3timages/blueline.gif width=33% height=2>

    If you are using VBS rather than VBA in Word, the syntax is going to be slightly different. I'll see if I can gin up a quick example. If not, someone else will have to pitch in.

  7. #7
    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 first page to a different printer? (word 97/20001)

    Here's a sample VBScript to batch print all the .doc files in a user-selected folder. It needs error checking in various places, and testing is hazardous unless you first set your default printer in Word to print to file or to PDF. Hope this helps.
    <pre>Sub PrintAll()
    Dim strFolder 'As String
    'Allowing the user to browse the file tree would be sexy, but...
    strFolder = InputBox("Enter complete path to folder to process", , "c:")
    If MsgBox("Print all Word documents (.doc) in " & vbCrLf & vbCrLf & _
    strFolder, vbQuestion + vbYesNo) = vbNo Then Exit Sub
    Dim oFSO, oFiles, oFile
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oFiles = oFSO.GetFolder(strFolder).Files
    ' error checking would be nice here, like are there any files?
    Dim wrdApp, wrdDoc
    'Word must be running in order for this to work
    Set wrdApp = GetObject(, "Word.Application")
    'Open, change page setup, and print each file
    For Each oFile In oFiles
    If LCase(Right(oFile.Name, 4)) = ".doc" Then
    'Add document to Word's document collection but do not add
    ' to recently opened files list
    Set wrdDoc = wrdApp.Documents.Open(oFile.Path, , , False)
    'Change Paper Source trays for first section
    wrdDoc.Sections(1).PageSetup.FirstPageTray = wdPrinterUpperBin
    wrdDoc.Sections(1).PageSetup.OtherPagesTray = wdPrinterLowerBin
    'Print document, but not background printing, to prevent
    ' premature Close and doc object destruction
    wrdDoc.PrintOut False
    'Close doc without saving changes
    wrdDoc.Close wdDoNotSaveChanges
    'Clean up object variable
    Set wrdDoc = Nothing
    End If
    Next
    'Clean up object variables
    Set wrdApp = Nothing 'does not quit Word!
    Set oFile = Nothing
    Set oFiles = Nothing
    Set oFSO = Nothing
    End Sub

    '----- Run the procedure -----

    PrintAll</pre>

    Note: This seems to run quite fast. My PDF print driver croaked on the third run-through, so it might make sense to try to slow it down a bit when there are a large number of files or they are very long.

    Note: To learn more about the FileSystemObject, search here in the Lounge for recent posts containing that string.

  8. #8
    New Lounger
    Join Date
    Jan 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing first page to a different printer? (word 97/20001)

    so far, i have one problem with it ... otherwise it is working great.... put it in an asp page, added a "wrdApp.quit()" statement outside the for each.... loop, and in win98 it seemed to kill the app and clear out memory....but i put in on win2k and there is one winword.exe for each document printed left behind in task manager.....is there some special syntax that i should use for asp? or, do you think that adding, say 1/2 second delay/sleep at the end of the for ... each loop, would allow it to close?
    thanks!

  9. #9
    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 first page to a different printer? (word 97/20001)

    I think possibly you are using CreateObject instead of GetObject when you create the reference to Word? For security reasons, you might not be able to get around this problem. See <!post=Post #130411,130411>Post #130411<!/post>.

    Or are you automating an instance of Word on the server itself? I haven't research the whys and hows of doing that...

  10. #10
    New Lounger
    Join Date
    Jan 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing first page to a different printer? (word 97/20001)

    the script runs and prints, but will not let me select the tray......i have tried wdPrinterUpperBin, wdPrinterLowerBin, wdPrinterMiddleBin, and wdPrinterLargeCapacityBin to no avail.....
    this is a laserjet 4000tn (3 trays total), and word 97.....
    is there any thought that upgrading to word 2000 might make a difference? or, does hp have some other secret reference to the three bins maybe? thanks! (current asp script attached)
    Attached Files Attached Files

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

    Re: Printing first page to a different printer? (word 97/20001)

    Try replacing the wdXXX constants by their value:

    wdPrinterLowerBin = 2
    wdPrinterManualFeed = 4

    etc. - you can look up the values in the Object Browser in Word VBE.

    I don't think that ASP pages "know" these constants, so they are all interpreted as 0, which corresponds to wdPrinterDefaultBin.

  12. #12
    New Lounger
    Join Date
    Jan 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing first page to a different printer? (word 97/20001)

    hansv, thank you ... i will try that out later today!!
    so, like this?:
    wrdDoc.Sections(1).PageSetup.OtherPagesTray = 2 'instead of wdPrinterLowerBin
    their numbering is certainly 'intuitive', huh? <G>

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

    Re: Printing first page to a different printer? (word 97/20001)

    You can either use:

    wrdDoc.Sections(1).PageSetup.OtherPagesTray = 2

    or "define" the constant in your script; then you can use it several times:

    Const wdPrinterLowerBin = 2
    wrdDoc.Sections(1).PageSetup.OtherPagesTray = wdPrinterLowerBin

    You might even put the definitions in an include file.

  14. #14
    New Lounger
    Join Date
    Jan 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing first page to a different printer? (word 97/20001)

    thanks very much..........it made all the difference in the world!

  15. #15
    New Lounger
    Join Date
    Jan 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing first page to a different printer? (word 97/20001)

    actually, no i'm using createobject, and the docs and the app dont seem to be responding to the close....can you see anything wrong with the code? (file attached)
    Attached Files Attached Files

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
  •