• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 984
  • Last Modified:

Outlook macro to print cover email as well as the attachments:

I have a macro that works great with the exception that it doesn't print the cover page of the emails along with the attachments. Need some help getting the email to print with the attachments as well.


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
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
For Each myItem In myOlSel
Set myAttachments = myItem.Attachments
If myAttachments.Count > 0 Then
For i = 1 To myAttachments.Count
myAttachments(i).SaveAsFile myOrt & myAttachments(i).DisplayName
strFile = myOrt & myAttachments(i).DisplayName
ShellExecute 0&, "print", strFile, 0&, 0&, 0&
Next i
End If
Set myItems = Nothing
Set myItem = Nothing
Set myAttachments = Nothing
Set myAttachment = Nothing
Set myOlApp = Nothing
Set myOlExp = Nothing
Set myOlSel = Nothing
End Sub

Open in new window

  • 2
1 Solution
David LeeCommented:
Hi, pover.

Add this line


somewhere after line #22 and before #25.
poverAuthor Commented:
thank you, that did the trick.
David LeeCommented:
You're welcome.  Glad I could help.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now