Consulting

Results 1 to 9 of 9

Thread: Solved: Print Open Files

  1. #1
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location

    Solved: Print Open Files

    Could a macro be written to print all the currently open Word files?
    ~Anne Troy

  2. #2
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Something like ..

    For each d in Documents
    d.printout
    next

    ??
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  3. #3
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Sweeeeeeeeeet.
    ~Anne Troy

  4. #4
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    I ended up with this. Is it correct?

    [vba]Option Explicit

    Sub PrintAll()

    Dim d As Document

    On Error Exit Sub
    For Each d In Documents
    d.PrintOut
    Next

    End Sub[/vba]
    ~Anne Troy

  5. #5
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Looks good. Sorry about the sloppy code
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  6. #6
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    No problem at all, Tony. I just want to make sure.
    Do ya want to go ahead and add it to the kb?

    ~Anne Troy

  7. #7
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Sure! Just like that? No clever stuff? Consider it done.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  8. #8
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Ann,

    I had trouble with the error handler you used when I tried it in Word 2000. The following worked in my old version of Word.

    [VBA]
    Option Explicit

    Sub PrintAll()
    Dim d As Document
    On Error GoTo ErrorHandler
    For Each d In Documents
    'uncomment the line that says d.PrintOut to actually print
    'and comment or delete the line that says d.PrintPreview
    'd.PrintOut
    d.PrintPreview
    Next

    ErrorHandler:
    Resume Next
    End Sub
    [/VBA]
    It's a good idea, thanks for it.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  9. #9
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Thanks, Steve!
    ~Anne Troy

Posting Permissions

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