AW: SendMail - VBA
14.01.2005 12:14:31
Russi
Hi Fab!
So einfach ist das leider auch nicht, per Sendmail kannst Du nur die ganze Datei verschicken. Also musst Du das betreffende Blatt erstmal kopieren (dadurch wird eine neue Datei erstellt) und diese Datei dann verschicken:
Sub Mail_nur_Blatt()
Dim AktBlatt$
Dim Pfad$
AktBlatt = activesheet.Name
Pfad = Activeworkbook.Path
If Activeworkbook.Path = "" Then
MsgBox ("Die Datei ist noch nicht gespeichert." & vbCr & _
"Erstellung eines Mail-Anhanges nicht möglich.")
Exit Sub
End If
Sheets(AktBlatt).Select
Sheets(AktBlatt).Copy
' Formeln in Festwerte
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
' Datei speichern
Activeworkbook.SaveAs _
FileName:=Pfad & Application.PathSeparator & AktBlatt & " " & Date & ".xls", _
FileFormat:=xlNormal, _
password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
Activeworkbook.SendMail ""
Activeworkbook.Close
If MsgBox("Temporäre Datei " & Activeworkbook.FullName & " löschen?", vbYesNo) = vbYes Then
Kill Pfad & Application.PathSeparator & AktBlatt & " " & Date & ".xls"
End If
End Sub
Viel Spaß damit!!!
Viele Grüße
Russi
www.Russi.de.tt