PDA

View Full Version : print attached pdf files from outlook



Friis
01-30-2013, 12:17 PM
Hi....

I have a "big" problem "at least for me" :(

I have tried to make a macro that can print attached PDF files from outlook, but the problem is that it saves all attached files and not only the pdf.
Is that possible?

Anyone know how to fix it?

Looking forward for the help:)

Copy of the macro.....

Kan gemme filer fra Indbakke, og udskrive pdf'er men fejler på billede filer
Public Sub PrintAttachments()
Dim Inbox As MAPIFolder
Dim Item As MailItem
Dim Atmt As Attachment
Dim Filename As String
Dim i As Integer
Dim ns As NameSpace
Dim PDFCount As Long
Dim a As Long

Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox).Parent.Folders.Item("indbakke")
For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
'‘ all attachments are first saved in the temp folder C:\Temp. Be sure to create this folder.
Filename = "C:\Temp\" & Atmt.Filename
Atmt.SaveAsFile Filename
'‘ please change the program folder accordingly if the Acrobat Reader is not installed on drive C:
Shell """C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe"" /h /p """ + Filename + """", vbHide
Next

'Item.Delete ‘remove this line if you don’t want the email be deleted automatically
Next
Set Inbox = Nothing
End Sub

skatonni
01-30-2013, 02:15 PM
Try

If (Right(Atmt, Len(Atmt) - InStrRev(Atmt, "."))) = "pdf" Then

Friis
01-30-2013, 11:26 PM
Thanks Skatonni

You are the man, thanks for the help :beerchug:


Best regards
Friis