AW: Images aus Tabellenblatt auf C speichern
09.05.2010 21:51:45
Josef
Hallo Kay,
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************
Option Explicit
Sub create() 'Speichern
'Tabellen und Bildname anpassen!
Export_Picture Sheets("Tabelle2").Shapes("Picture 1"), "C:\Temp\temp.gif"
End Sub
Sub destroy() 'Löschen
On Error Resume Next
Kill "C:\Temp\temp.gif"
End Sub
Private Function Export_Picture(myShape As Shape, FileName As String) As Long
'Idea by Nepumuk
Dim myChart As Chart, myChartObject As ChartObject
Dim strFilter As String
On Error GoTo ErrExit
Application.ScreenUpdating = False
Application.DisplayAlerts = False
strFilter = UCase(Right(FileName, 3))
Select Case strFilter
Case "GIF", "JPG", "PNG"
Case Else
MsgBox "Ungültiges Grafikformat!" & vbLf & vbLf & "Export als '" & FileName & "' nicht möglich.", _
vbInformation, "Export_Picture"
Err.Raise vbObjectError + 1024
End Select
Set myChart = Charts.Add
Set myChartObject = ActiveChart.ChartObjects.Add(0, 0, myShape.Width, myShape.Height)
myShape.Copy
With myChartObject
With .Chart
.ChartArea.Border.LineStyle = xlLineStyleNone
.Paste
.Export FileName:=FileName, FilterName:=strFilter, Interactive:=False
End With
.Delete
End With
myChart.Delete
ErrExit:
Export_Picture = Err.Number = 0
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Set myChart = Nothing
Set myChartObject = Nothing
Set myShape = Nothing
End Function
Gruß Sepp