Code funktioniert bei *.xltm nicht
01.03.2023 13:24:28
Jarod
Ich habe folgenden Code um aus einem Excel ein Mail zu erstellen welches die Exceldatei als Anhang verschicken soll. Wenn ich die Datei als *.xlsm speichere funktioniert der Code einwandfrei. Wenn ich die Datei aber als Vorlage *.xltm speichere und dann öffne funktioniert der Code nicht. Er hängt dann bei ".attachments.Add Anhang". Wo liegt der Fehler?
Besten Dank für eure Hilfe.
Private Sub Mailversand_Click()
Dim Nachricht As Object, OutlookApplication As Object
Set OutlookApplication = CreateObject("Outlook.Application")
Dim Anhang As String
Anhang = ThisWorkbook.FullName
Set Nachricht = OutlookApplication.CreateItem(0)
With Nachricht
.To = "xxxxx@xxxxx.xx"
.Subject = "Eröffnungsauftrag"
.attachments.Add Anhang
.Display
'.Mail.Send
End With
Set OutlookApplication = Nothing
Set Nachricht = Nothing
End Sub