ArnoD1995
05-02-2016, 12:43 AM
Best all,
Well, i've created the following macro ('created' > mostly copied from others), but ran into a problem which seems very strange to me.
Sub Print_bijlagen()
Dim Inbox As MAPIFolder
Dim Item As MailItem
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
If MsgBox("Weet u zeker dat u alle bijlagen van mails uit de geselecteerde map wilt afdrukken? (PDF only!)", vbOKCancel, "Buitelaar Houtconstructies B.V.") = vbOK Then
Set Inbox = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.folders.Item("Printmap")
For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
FileName = "C:\Temp\" & Atmt.FileName & i
Atmt.SaveAsFile FileName
i = i + 1
Shell """C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"" /h /p """ + FileName + """", vbHide
Next
Next
Set Inbox = Nothing
Else
MsgBox "Afdrukken geanuleerd"
End If
End Sub
(Texts are in dutch)
What it does is printing all attachments (pdf only) from the mails in a specific folder, in this instance it's the folder called "PRINTMAP".
It works great on my pc, so i tried installing it on my colleagues' pc, but unfortanately it's not working. It goes into error on the following line:
Atmt.SaveAsFile FileName
I already adapted the path to the adobe reader, but it won't work (didn't expect that to fix the error either, as it is 'later' in the macro..)
I hope you guys can help me finding the problem of the not working macro on my colleagues' pc.
Both pc's use Outlook 2013, win 7 64-bit, they are completely identical.
Best regards,
Arno Dekkers
Well, i've created the following macro ('created' > mostly copied from others), but ran into a problem which seems very strange to me.
Sub Print_bijlagen()
Dim Inbox As MAPIFolder
Dim Item As MailItem
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
If MsgBox("Weet u zeker dat u alle bijlagen van mails uit de geselecteerde map wilt afdrukken? (PDF only!)", vbOKCancel, "Buitelaar Houtconstructies B.V.") = vbOK Then
Set Inbox = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.folders.Item("Printmap")
For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
FileName = "C:\Temp\" & Atmt.FileName & i
Atmt.SaveAsFile FileName
i = i + 1
Shell """C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"" /h /p """ + FileName + """", vbHide
Next
Next
Set Inbox = Nothing
Else
MsgBox "Afdrukken geanuleerd"
End If
End Sub
(Texts are in dutch)
What it does is printing all attachments (pdf only) from the mails in a specific folder, in this instance it's the folder called "PRINTMAP".
It works great on my pc, so i tried installing it on my colleagues' pc, but unfortanately it's not working. It goes into error on the following line:
Atmt.SaveAsFile FileName
I already adapted the path to the adobe reader, but it won't work (didn't expect that to fix the error either, as it is 'later' in the macro..)
I hope you guys can help me finding the problem of the not working macro on my colleagues' pc.
Both pc's use Outlook 2013, win 7 64-bit, they are completely identical.
Best regards,
Arno Dekkers