PDF erzeugen aber mit Dataum aus Zelle
11.11.2022 07:37:34
Thomas
ich bin neue im Forum und höre auf den Namen Thomas. Schon oft habe ich mich euerer Kompetenz in Excel bedient wenn ich nicht weiter kam und hoffe hier weiterhin viel zu lernen.
Ich habe mir ein Makro gebastelt welches aus dem aktiven Sheet eine PDF Datei erstellt und als Mail vie Outlook versendet. Der läuft auch. Ich möchte aber nun zusätzlich das diese PDF nicht nur Test.pdf heißt sondern hintendrann noch das Datum welches in Zelle A4 ist anhängt. Also Test 11.11.2022. Pdf.
Hat jemand einen Ansatz für mich? Herzlichen Dank
Sub sendPDf()
Dim app As Object
Dim file As String
Dim isNew As Boolean
file = ActiveSheet.Name & ".pdf"
ActiveSheet.ExportAsFixedFormat xlTypePDF, Environ("TEMP") & "\" & file
On Error Resume Next
Set app = GetObject(, "Outlook.Application")
If app Is Nothing Then
Set app = CreateObject("Outlook.Application")
isNew = True
End If
With app.CreateItem(0)
.To = ""
.CC = ""
.BCC = ""
.Subject = "Anlage: " & file & vbLf & vbLf & Range("ab2")
.Subject = "Test Abrechnung (" & Range("a4") & ")"
.Attachments.Add Environ("TEMP") & "\" & file
.ReadReceiptRequested = True
.Display 'Email anzeigen
End With
If isNew Then app.Quit
End Sub