@mumpel: mit TAB meinte ich das Sheet, das gerade offen ist. Ich hoffe das ist die richtige Bezeichnung. Also ich meine die Blääter unten in Excel auf denen man von Blatt zu Blatt wechseln kann.
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é