Hallo zusammen,
ich habe folgenden VBA Code als Makro in Outlook hinterlegt. Er soll nur die Anhänge ausgewählter E-Mails drucken. Dies aber nicht auf dem hinterlegten Standarddrucker sondern auf einem anderen Netzwerkdrucker.
Leider funktioniert der Wechsel nicht und er druckt weiterhin auf meinem Standarddrucker. Könnt ihr mir helfen?
Vielen Dank im Voraus.
Gruß
Timo
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
Dim printer As String
printer = Chr(34) & "\\HSVM09\2. OG Flur auf Ne 26:" & Chr(34)
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, "printto", sFile, printer, vbNullString, 0
End Select
Next
End If
End Sub
|