-
Printing attachments from a selected email
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.
[VBA]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
[/VBA]
Last edited by Edwardo; 12-23-2009 at 02:45 AM.
-
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.
-
is it no really know? or again is it the way I asked the question??
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules