Printing attachments Duplex

  • Thread starter Thread starter Terry
  • Start date Start date
T

Terry

I'm not sure this is entirely possible, but would appreciate any advice.

I have a user who gets emails containing large Word attachments.
What he'd like, is to be able to print the email with its attachment, but
printing it 2 sides per page and double sided !! (doesnt want much does
he?).

I can acheive this in Word quite easily, but the user is too lazy to open up
Word every time and insists that he wants to do it in Outlook.

Does anybody have any ideas?
 
The PrintOut method is the only method that Outlook exposes for Printing, and it can only use the default print settings.

What we can do is save the Word document to a local directory, automate Word to open it and print it out with two sides per page. It doesn't look like you can control double-sided printing though. Try the code below on a currently selected message in the active folder that has a Word attachment.

You may want to play with Word's PrintOut method and the PageSetup object to do other things, and also add some FileSystemObject stuff to delete the attachment that was saved.

Sub PrintAttachedWordDoc()
Dim objMsg As Object, objAtt As Outlook.Attachment
Dim objDoc As Word.Document, objWord As Word.Application, objPageSetupOptions As Word.Options

Set objMsg = Application.ActiveExplorer.Selection.Item(1)
If objMsg Is Nothing Then Exit Sub
If objMsg.Attachments.Count <> 1 Then Exit Sub

Set objAtt = objMsg.Attachments.Item(1)
objAtt.SaveAsFile "C:\Temp\" & objAtt.FileName

Set objWord = New Word.Application
Set objDoc = objWord.Documents.Open("C:\Temp\" & objAtt.FileName)
objDoc.PageSetup.TwoPagesOnOne = True
objDoc.PrintOut
objDoc.Close
objWord.Quit
Set objWord = Nothing
Set objDoc = Nothing
Set objMsg = Nothing
Set objAtt = Nothing
End Sub
 
The PrintOut method is the only method that Outlook exposes for Printing, and it can only use the default print settings.

What we can do is save the Word document to a local directory, automate Word to open it and print it out with two sides per page. It doesn't look like you can control double-sided printing though. Try the code below on a currently selected message in the active folder that has a Word attachment.

You may want to play with Word's PrintOut method and the PageSetup object to do other things, and also add some FileSystemObject stuff to delete the attachment that was saved.

Sub PrintAttachedWordDoc()
Dim objMsg As Object, objAtt As Outlook.Attachment
Dim objDoc As Word.Document, objWord As Word.Application, objPageSetupOptions As Word.Options

Set objMsg = Application.ActiveExplorer.Selection.Item(1)
If objMsg Is Nothing Then Exit Sub
If objMsg.Attachments.Count <> 1 Then Exit Sub

Set objAtt = objMsg.Attachments.Item(1)
objAtt.SaveAsFile "C:\Temp\" & objAtt.FileName

Set objWord = New Word.Application
Set objDoc = objWord.Documents.Open("C:\Temp\" & objAtt.FileName)
objDoc.PageSetup.TwoPagesOnOne = True
objDoc.PrintOut
objDoc.Close
objWord.Quit
Set objWord = Nothing
Set objDoc = Nothing
Set objMsg = Nothing
Set objAtt = Nothing
End Sub
 
Thanks Eric, that's very helpfull.
I'll have a play with the code and see what happens.


Eric Legault said:
The PrintOut method is the only method that Outlook exposes for Printing,
and it can only use the default print settings.
What we can do is save the Word document to a local directory, automate
Word to open it and print it out with two sides per page. It doesn't look
like you can control double-sided printing though. Try the code below on a
currently selected message in the active folder that has a Word attachment.
You may want to play with Word's PrintOut method and the PageSetup object
to do other things, and also add some FileSystemObject stuff to delete the
attachment that was saved.
Sub PrintAttachedWordDoc()
Dim objMsg As Object, objAtt As Outlook.Attachment
Dim objDoc As Word.Document, objWord As Word.Application,
objPageSetupOptions As Word.Options
 
Back
Top