mit dem nachfolgenden Code werden Zellbereiche einer Tabelle als Screenshot (PNG) in einer Datei gespeichert.
Excel stürzt allerdings beim Schließen der Datei dann regelmäßig ab.
Hat hierzu jemand einen Tipp. Danke für eure Mühe.
Viele Grüße
Niko
Private Sub CommandButton241_Click()
Dim objChart As ChartObject
Dim ws As Excel.Worksheet
Dim pic As Picture
Dim filename As String
Set bereich = Application.InputBox(prompt:="Bereich markieren!", Title:="EKZ", Type:=8)
bereich.Copy
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set ws = ThisWorkbook.Worksheets.Add
Set pic = ws.Pictures.Paste(Link:=True)
pic.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Set objChart = ws.ChartObjects.Add(0, 0, pic.Width, pic.Height)
With objChart.Chart
.Paste
.Export filename:="L:\Privat\Haushaltsmanager\Haushaltsbuch\" & "EKZ" & ".png", FilterName:=" _
_
PNG"
End With
ws.Delete
Set ws = Nothing
Set pic = Nothing
Set objChart = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub