PDA

View Full Version : Printing attachments from a selected email



Edwardo
12-22-2009, 08:37 PM
Hello everyone,
First I would like to say thank you to everyone that contributed to this forum. Im still new to VBA and currently working my first piece of code. I manage to create a VBA to check for attachments for the selected item and print it out if it is PDF. However I'm few programs 1) How tell it to print (Word, Excel, etc) with other software 2) how to close the Acrobat reader (other softwares) when done


below is the code I have been working on.

Sub PrintAttachment()
Dim MyItem As Outlook.MailItem
Dim Atmt As Attachment
Dim KillFile As String



On Error Resume Next
Select Case TypeName(Application.ActiveWindow)
Case "Explorer"
Set MyItem = ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set MyItem = ActiveInspector.CurrentItem
Case Else
End Select
On Error GoTo 0

If MyItem Is Nothing Then
GoTo ExitProc
End If

For Each Atmt In MyItem.Attachments
FileName = "C:\Email Attachments\" & Atmt.FileName
Atmt.SaveAsFile FileName
If UCase(Right(Atmt.FileName, 3)) = "PDF" Then
Shell """C:\Program Files\Adobe\reader 8.0\Reader\AcroRd32.exe"" /t """ _
& FileName & """"
If UCase(Right(Atmt.FileName, 3)) = "Doc" Then
PrintAtt (FILE_PATH & Atmt.FileName)

End If

Next Atmt



MsgBox "I found " & MyItem.Attachments.Count & " attachments"

ExitProc:
Set MyItem = Nothing

Kill "C:\Email Attachments\*.*"



End Sub

Edwardo
12-27-2009, 08:05 PM
well this is very discouraging.. my first post and no reply=(.

Am I asking the question in a wrong way? if so, please let me know .. at least I can correct myself.

Edwardo
12-29-2009, 06:42 PM
is it no really know? or again is it the way I asked the question??

Edwardo
01-17-2010, 06:54 PM
bump