How to save a graph as jpg file in Excel 2007

A

Athena

Hello,

I need to save some Excel Graphs as jpg files. How can I do it?

Thank you.

Athena
 
A

Andy Pope

Hi,

Requires code. Syntax: Activechart.Export <filename> , <filtertype>

You can use this in the immediate window,(ALT+F11 CTRL+G)

Activechart.export "C:\mychart.jpg"

Cheers
Andy
 
A

Athena

Hello Andy,

Thank you very much. It worked. Do you happened to know how to set the
resolution of the jpeg image as well?

Athena
 
J

Jon Peltier

There is no control over the resolution of the exported image. You get
whatever the resolution of the screen is.

By the way, JPG is really the wrong format for a chart. Most computer
graphics are better suited to PNG or GIF, which are also possible using the
Chart.Export method Andy provided. The JPG format was designed for
photographic images, which have areas of gradually changing colors and
shadows. JPG does poorly where there are sharp transitions of colors, for
example, along the edges of shapes and in text. For these situations, which
are what charts are made of, PNG is probably your best choice.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


Athena said:
Hello Andy,

Thank you very much. It worked. Do you happened to know how to set the
resolution of the jpeg image as well?

Athena
 
A

Athena

Jon,

Thank you. I did not know this.I shall try to save them as png files.

Athena

Jon Peltier said:
There is no control over the resolution of the exported image. You get
whatever the resolution of the screen is.

By the way, JPG is really the wrong format for a chart. Most computer
graphics are better suited to PNG or GIF, which are also possible using
the Chart.Export method Andy provided. The JPG format was designed for
photographic images, which have areas of gradually changing colors and
shadows. JPG does poorly where there are sharp transitions of colors, for
example, along the edges of shapes and in text. For these situations,
which are what charts are made of, PNG is probably your best choice.

- Jon
 
Joined
Jul 6, 2010
Messages
1
Reaction score
0
Thank you for the post

Thank you Andy, i was looking for a solution too export graphs in PNG format, it work perfectly.

take care all.
 
Joined
Apr 2, 2011
Messages
3
Reaction score
0
Macro you can setup on the Toolbar to quickly export charts to a file in same directory as the workbook with filename same as the title of the chart.

Sub CopyChartToGIF()
'Take ActiveChart and copy it as a GIF image to the same directory as the Workbook is in and name it with the Chart_Title with spaces replaced with underscores.
Dim chtCopyChart As Chart, sCurrentDirectory As String, sFileName As String
Dim x As Integer, CellCharacter As String

Set chtCopyChart = ActiveChart
sCurrentDirectory = ActiveWorkbook.Path
sFileName = chtCopyChart.ChartTitle.Text

For x = 1 To Len(sFileName)
CellCharacter = Mid(sFileName, x, 1)
If CellCharacter Like "[</*\?%]" Then
sFileName = Replace(sFileName, CellCharacter, "_", 1) ', Replaces all illegal filename characters with "_"
End If
If Asc(CellCharacter) <= 32 Then
sFileName = Replace(sFileName, CellCharacter, "_", 1) ' Replaces all non printable characters with "_"
End If

Next

sFileName = sFileName & ".gif"
sFileName = sCurrentDirectory & "\" & sFileName

chtCopyChart.Export Filename:=sFileName, FilterName:="GIF"

MsgBox "Chart copied to " & sFileName, vbOKOnly, "Success!"


End Sub
 
Joined
May 6, 2011
Messages
1
Reaction score
0
Is there a way to use rfengr's code and save the gif file not with the chart name, but the worksheet name instead?

This site is great, thanks so much!
 
Joined
Apr 2, 2011
Messages
3
Reaction score
0
Bryang0906, here you go. Simply substitute ActiveSheet.Name to sFileName. Simple.

Sub CopyChartToGIF()
'Take ActiveChart and copy it as a GIF image to the same directory as the Workbook is in and name it with the Active Worksheet Name with spaces replaced with underscores.
Dim chtCopyChart As Chart, sCurrentDirectory As String, sFileName As String
Dim x As Integer, CellCharacter As String

Set chtCopyChart = ActiveChart
sCurrentDirectory = ActiveWorkbook.Path
sFileName = ActiveSheet.Name

For x = 1 To Len(sFileName)
CellCharacter = Mid(sFileName, x, 1)
If CellCharacter Like "[</*\?%]" Then
sFileName = Replace(sFileName, CellCharacter, "_", 1) ', Replaces all illegal filename characters with "_"
End If
If Asc(CellCharacter) <= 32 Then
sFileName = Replace(sFileName, CellCharacter, "_", 1) ' Replaces all non printable characters with "_"
End If

Next

sFileName = sFileName & ".gif"
sFileName = sCurrentDirectory & "\" & sFileName

chtCopyChart.Export Filename:=sFileName, FilterName:="GIF"

MsgBox "Chart copied to " & sFileName, vbOKOnly, "Success!"


End Sub
 
Joined
May 10, 2011
Messages
11
Reaction score
0
Hello,

I need to save some Excel Graphs as jpg files. How can I do it?

Thank you.

Athena


After your chart has been prepared go to follow the steps to covert excel cahrt into jpg format
1. File > Save as > Select "Web Page (*.htm;*.html)
2.Choose Selection: Chart radio button
3. Click on Publish
4. Choose the destination where you want to save the chart by clciking on Browse
5. Again click on Publish
6. Then open the file you have saved (e.g. Chart.htm or Cahrt.html)
7. After opening the file right click on the chart and choose Save Image As
8. Then type the file name chart.jpg (in this you have to chnage the format by because by default it would be saved in gif format so you need to change it into jpg format so must save the file name with .jpg extension)
9. Click on save (please choose the destination where you want to save)
10. Now your excel chart is in jpf format
HOPE IT WOULD BE USEFUL . THANKS
 
Joined
May 17, 2011
Messages
1
Reaction score
0
hi rfengr_1,

your macro works great to save one chart to a .gif by the charts file name. thank you very much. I was wondering if it would be possible to have a macro to save multiple charts by the same method? i basically have about 10 charts in my excel file and the charts constantly update. so it would be great if that macro could save all charts the same way.

Thank you for your help.
 
Joined
Feb 14, 2012
Messages
1
Reaction score
0
After your chart has been prepared go to follow the steps to covert excel cahrt into jpg format
1. File > Save as > Select "Web Page (*.htm;*.html)
2.Choose Selection: Chart radio button
3. Click on Publish
4. Choose the destination where you want to save the chart by clciking on Browse
5. Again click on Publish
6. Then open the file you have saved (e.g. Chart.htm or Cahrt.html)
7. After opening the file right click on the chart and choose Save Image As
8. Then type the file name chart.jpg (in this you have to chnage the format by because by default it would be saved in gif format so you need to change it into jpg format so must save the file name with .jpg extension)
9. Click on save (please choose the destination where you want to save)
10. Now your excel chart is in jpf format
HOPE IT WOULD BE USEFUL . THANKS



I needed help with this as well. All the steps worked until I needed to save the image as a jpg file. Even though I input the file extension it did not save as a Jpg. I also did not have the option to "save image as", just a save as option. Not converting a graph but design that has text and an image added to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top