Excel:Export Diagram as Image File
Excel is not capable to export diagrams into image files out-of-the-box. However, VisualBasic provides capabilities for doing this.
Makro Code to Export Image File
Sub exportDiagram2Image() Dim strGrafikName As String strGrafikName = Application.GetSaveAsFilename( _ "diagramm", FileFilter:="GIF-Format (*.gif)," & _ " *.gif,JPG-Format (*.jpg), *.jpg") On Error GoTo ErrorHandler ActiveChart.Export Filename:=strGrafikName, _ FilterName:=Right(strGrafikName, 3) Exit Sub ErrorHandler: If Err.Number = 91 Then MsgBox "Export nicht möglich. " & _ "Sie haben kein Diagramm ausgewählt.", _ vbCritical + vbOKOnly, _ "Diagramm als Grafik exportieren" Else MsgBox "Der folgende Fehler ist aufgetreten: " & _ Err.Number & " - " & Err.Description, vbCritical + _ vbOKOnly, "Diagramm als Grafik exportieren" End If End Sub
Quelle für den Code: Newsletter von SmartTools Excel-Weekly vom 23.09.2003
Excel Add-In Diagram2ImageExporter
Attached to this Wiki page you can find an Excel Add-In that provides the makro described above and can be installed persistently in your Excel installation. This enables you to add this makro to your toolbar. Datei:Diagram2ImageExporter.zip
Installation:
- Save the add in file in your Excel Add-In Directory (e.g., C:\Users\benjamin\AppData\Roaming\Microsoft\AddIns)
- open Excel
- go to File->Options->Add-Ins->Manage Excel Add-Ins
- Activate the Diagram2ImageExporter add-in
- Optionally, customize your toolbar and add a button for this new makro
Usage: Mark a diagram and run the makro (click on the button created previously) In the new dialog box open your target directory and provide a file name. The exported image type depends on the file extension provided with the filename. Available options are: .gif and .jpg