GrayStrickland
asked on
VB Code to Print All Emails in a PST
How can i modify this code:
so that it does *NOT* print attachments? Or better yet, asks me whether I want to print attachments, giving me the option at runtime.
My ultimate goal is to be able print all emails in a PST to an Acrobat PDF. I have Acrobat 9 Pro installed. I can accept one PDF with all the emails in it, or one PDF per email *chain*, or one PDF per individual email.
NOTE: code snippet written by Genius-level BlueDevilFan (@techniclee).
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
Dim objFSO As Object, _
objTempFolder As Object
Sub PrintController()
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTempFolder = objFSO.GetSpecialFolder(2)
PrintItems Application.ActiveExplorer.CurrentFolder
Set objTempFolder = Nothing
Set objFSO = Nothing
MsgBox "Finished"
End Sub
Public Sub PrintItems(olkFolder As Outlook.Folder)
Dim olkAttachment As Outlook.Attachment, _
olkItem As Object, _
olkSubfolder As Outlook.Folder
On Error Resume Next
For Each olkItem In olkFolder.Items
For Each olkAttachment In olkItem.Attachments
olkItem.PrintOut
olkAttachment.SaveAsFile objTempFolder & "\" & olkAttachment.FileName
ShellExecute 0&, "print", objTempFolder & "\" & olkAttachment.FileName, 0&, 0&, 0&
Next
Next
For Each olkSubfolder In olkFolder.Folders
PrintItems olkSubfolder
Next
On Error GoTo 0
Set olkItem = Nothing
Set olkAttachment = Nothing
End Sub
so that it does *NOT* print attachments? Or better yet, asks me whether I want to print attachments, giving me the option at runtime.
My ultimate goal is to be able print all emails in a PST to an Acrobat PDF. I have Acrobat 9 Pro installed. I can accept one PDF with all the emails in it, or one PDF per email *chain*, or one PDF per individual email.
NOTE: code snippet written by Genius-level BlueDevilFan (@techniclee).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.