AW: Re: Eine Datei als Excel und Pdf mit Outlook
05.02.2015 18:06:05
mumpel
Hallo!
Option Explicit
Public Sub SendAsPdfAndXLSAttach()
Dim olApp As Object
Dim strPath As String
Dim strPDF As String
Dim strXLSX As String
strPath = ActiveWorkbook.Path & "\"
strPDF = ActiveSheet.Name & ".pdf"
strXLSX = ActiveSheet.Name & ".xlsx"
With ActiveSheet
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strPath & strPDF, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
.Copy
End With
With ActiveWorkbook
.SaveAs Filename:=strPath & strXLSX, FileFormat:=xlOpenXMLWorkbook
.Close
End With
Set olApp = CreateObject("Outlook.Application")
With olApp.CreateItem(0)
.To = "test@test.de"
.Subject = "Test"
.htmlBody = "Hallo,<br><br>nur ein Test.<br><br>Gruß, Max"
.Attachments.Add strPath & strPDF
.Attachments.Add strPath & strXLSX
.Display
End With
Kill strPath & strPDF
Kill strPath & strXLSX
End Sub
VBA/HTML - CodeConverter für Office-Foren, AddIn für Office 2002-2013 - in VBA geschrieben von Lukas Mosimann. Projektbetreuung:mumpel
Code erstellt und getestet in Office 15 - mit VBAHTML 12.6.0
Gruß, René