Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Aug 2004
    Posts
    361
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print All (Word, Outlook)

    The following will print all open Word docs and then close them.

    Sub PrintAll()
    '
    'To print all open documents not saving changes'

    Dim aDoc As Document
    For Each aDoc In Documents
    aDoc.PrintOut
    aDoc.Close SaveChanges:=wdNotSaveChanges
    Next
    End Sub

    As one of our committees gets agendas with both links to docs and msg, I am wondering if it is possible to modify this code to print all the open docs and msg.

    Thanks.

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,507
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Re: Print All (Word, Outlook)

    Are the msg files embedded in a Word doc or are they Outlook message attachments?
    -John ... I float in liquid gardens
    [acronym title="Gday mate!"][/acronym] [acronym title="What up Dude?"][/acronym] UTC -7±DS

  4. #3
    3 Star Lounger
    Join Date
    Aug 2004
    Posts
    361
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print All (Word, Outlook)

    They are embedded. Just want to go through the document open all docs and msg and then be able to print all at once.

    As an after thought, the code could possibly be changed to auto open all docs and msgs and then print them all, could it not?

  5. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,507
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Re: Print All (Word, Outlook)

    Do you mean embedded in Word? I don't believe that Word recognizes the *.msg format. (If you try to open a *.msg with Word manually Word doesn't.) This should be simple but it isn't, UNLESS there are API ways to do this, and I have no API programming skills.

    Outlook is a very different object model from Word or Excel, you may need to save the embedded msg file to a temporary folder, instance Outlook and use shell with (untested aircode)

    Shell "outlook.exe /recycle /p " & Chr(34) & <messagepathmsgfilename.msg> & Chr(34), vbHide

    command line parameters. However the command line notes in Help state that this doesn't work with HTM messages - I don't know if that means *.msg files with .htm format, or if it means messages saved in .htm format. If the former, then you may need to use something like (untested aircode):

    Shell "outlook.exe /recycle /f " & Chr(34) & <messagepathmsgfilename.msg> & Chr(34), vbNormalFocus
    DoEvents
    ActiveInspector.CurrentItem.Printout
    ActiveInspector.Close

    And this will be all visible to the user.
    -John ... I float in liquid gardens
    [acronym title="Gday mate!"][/acronym] [acronym title="What up Dude?"][/acronym] UTC -7±DS

  6. #5
    3 Star Lounger
    Join Date
    Aug 2004
    Posts
    361
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print All (Word, Outlook)

    Clarification .. user will open the original Word document which then has a number of embedded msg and doc. User needs to open all of the embedded items and then print them. Obviously the msg opens in Outlook and the docs in Word. Once open, they would like to be able to print everything with one piece of code if possible.


    Is it possible or not to write one piece of code that will print open Word documents and Outlook email is the best way to describe the question?

  7. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,507
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Re: Print All (Word, Outlook)

    Yes, but it's going to be complex, see my prior post. To loop through the embedded documents see HansV's <post#=495159>post 495159</post#>; you'll need to use the InlineShapes.Creator property to choose which application is used as the engine to print the document.
    -John ... I float in liquid gardens
    [acronym title="Gday mate!"][/acronym] [acronym title="What up Dude?"][/acronym] UTC -7±DS

Posting Permissions

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