AW: Excel Bereich in Mail kopieren
09.06.2021 20:24:12
PeTeR
Hallo Lutz,
dann musst du 1) den Bereich als Bild speichern und dann 2) das Bild in Outlook einfügen:
1)
Sub Range_To_Image()
Dim objPict As Object, objChrt As Chart
Dim rngImage As Range, strFile As String
On Error GoTo ErrExit
With Sheets("Tabelle1") 'Tabellenname - Anpassen!
Set rngImage = .Range("C4:D6")
rngImage.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
.PasteSpecial Format:="Bitmap", Link:=False, DisplayAsIcon:=False
Set objPict = .Shapes(.Shapes.Count)
strFile = "D:\ToDo\meinBild.gif" 'Pfad und Dateiname für das Bild
objPict.Copy
Set objChrt = .ChartObjects.Add(1, 1, objPict.Width + 8, objPict.Height + 8).Chart
objChrt.Paste
objChrt.Export strFile
objChrt.Parent.Delete
objPict.Delete
End With
ErrExit:
Set objPict = Nothing
Set objChrt = Nothing
Set rngImage = Nothing
End Sub
2)
Sub Email_erstellen()
Dim objOutlook As Object, objMail As Object
Dim sText
sText = sText & ""
Set objOutlook = CreateObject(Class:="Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
With objMail
.To = "Empfänger"
.Subject = "Betreff"
.htmlbody = sText
.display
End With
End Sub
Kann man alles im Web finden ;-)
Viel Erfolg
PeTeR