ich möchte gerne ein Excel Formular mit einem makro erstellen. Soweit habe ich alles hinbekommen nur hätte ich gerne den PDF Namen Dynamisch, so das er sich aus 4 Zellen erstellt und die auf dem Desktop Speichert und im Outlook eine E-Mail öffnet und im Anhang die PDF ist.
mein Code sieht wie Folgt aus.
Sub PDFundSenden()
ChDir Environ("homepath") & "\Desktop"
ActiveSheet.ExportAsFixedFormat Type:=xlsmTypePDF, Filename:= _
Environ("homepath") & "\Desktop\Urlaubsantrag.pdf", OpenAfterPublish:=True
Dim Outlook As Object
Dim OutlookMailItem As Object
Dim myAttachments As Object
Set OutlookApp = CreateObject("outlook.application")
Set OutlookMailItem = OutlookApp.CreateItem(0)
Set myAttachments = OutlookMailItem.Attachments
With OutlookMailItem
.to = Range("AL1")
.Subject = Range("D1") & " " & Range("A1") & Range("D3") & " " & Range("AA1")
.Body = "Hiermit beantrage ich Urlaub. Mein Urlaubsantrag ist angehängt."
myAttachments.Add Environ("homepath") & "\Desktop\Urlaubsantrag.pdf"
'.send
.Display
End With
Set OutlookApp = Nothing
Set OutlookMailItem = Nothing
End Sub