Hallo zusammen,
ich habe folgenden Code um PDF Mail Anhänge automatisch zu drucken. Bei dem Code speichert er die Sachen aber einfach unter "Dokumente". Kann man dem Code noch einen speziellen Pfad mitgeben wo die Dateien abgelegt werden sollen?
Vielen Dank im Voraus.
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
Public Sub PrintSelectedAttachments()
Dim Exp As Outlook.Explorer
Dim Sel As Outlook.Selection
Dim obj As Object
Set Exp = Application.ActiveExplorer
Set Sel = Exp.Selection
For Each obj In Sel
If TypeOf obj Is Outlook.MailItem Then
PrintAttachments obj
End If
Next
End Sub
Private Sub PrintAttachments(oMail As Outlook.MailItem)
On Error Resume Next
Dim colAtts As Outlook.Attachments
Dim oAtt As Outlook.Attachment
Dim sFile As String
Dim sFileType As String
Set colAtts = oMail.Attachments
If colAtts.Count Then
For Each oAtt In colAtts
sFileType = LCase$(Right$(oAtt.FileName, 4))
Select Case sFileType
Case ".pdf"
sFile = ATTACHMENT_DIRECTORY & oAtt.FileName
oAtt.SaveAsFile sFile
ShellExecute 0, "print", sFile, vbNullString, vbNullString, 0
End Select
Next
End If
End Sub
|