Printing multiple attachments at once

G

Guest

I often receive multiple attachments in my emails.

I have tried to print them all at once by selecting them all but it does
seem to work. I always end up printing them one by one, which I find time
consuming.

Has anyone got a solution to this please.

Thanks.

Yappy Box
 
G

Guest

Hi Yappy,

Here is a macro that will do it. The only problem with it is if there are
multiple PDF attachments - those will print sporadically unless your default
printer uses a postscript driver. It works consistently for all other types
of attachments. Basically, it saves the attachments to c:\program
files\microsoft office (you can change that path if you would like) and then
prints the saved file to your default printer.


Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Sub PrintAttachment()
Dim myItems, myItem, myAttachments, myAttachment As Object
Dim myOrt As String
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim strFile As String

'Set destination folder
myOrt = "C:\program files\microsoft office\"


On Error Resume Next
'work on selected items
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
'for all items do...
For Each myItem In myOlSel
'point on attachments
Set myAttachments = myItem.Attachments
If myAttachments.Count > 0 Then
'for all attachments do...
For i = 1 To myAttachments.Count
'save them to destination
myAttachments(i).SaveAsFile myOrt &
myAttachments(i).DisplayName
strFile = myOrt & myAttachments(i).DisplayName

ShellExecute 0&, "print", strFile, 0&, 0&, 0&
NextOne:

Next i

myItem.Save

End If
Next
Set myItems = Nothing
Set myItem = Nothing
Set myAttachments = Nothing
Set myAttachment = Nothing
Set myOlApp = Nothing
Set myOlExp = Nothing
Set myOlSel = Nothing



End Sub
 
G

Guest

Many Thanks MarieJ for your reply and your help.
I have never written macros so I would not know how to do this although it
would be very good to have finally a solution to my problem.
I have created macros in Word (Office 2003) many times using the Tools
feature (Tools, macro, new etc...) but not actually written a macro. I do
not know where to start.
May be with more experience in the future I will be able to handle it. I am
learning everyday so who knows! I won't give up and keep your reply for THAT
day, when I can finally write macros.
Have a nice day. Yappy Box
 
G

Guest

I'll be happy to email you the steps - it's fairly easy. Send your private
contact information to me at (e-mail address removed).

MarieJ
 
S

Smith

Hi All,

I have tried the script also. Just have 2 questions. May i ask here?

1. Is the PDF issue MarieJ mentioned is that, for e.g., i print 4 documents
maybe only 3 comes out?
2. The Macro Script editor suddently comes out periodically.

Any idea of it?
Many thanks
 
A

Alan in NJ

This macro works beautifully!
Is there a way to embed it in an InBox Rule so when a message I receive each
day with a pdf attachement arrives it will print automatically?
Thanks.

Alan S.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top