How to save a graph as jpg file in Excel 2007

Discussion in 'Microsoft Excel Charting' started by Athena, May 14, 2008.

  1. Athena

    Athena Guest

    Hello,

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

    Thank you.

    Athena
     
    Athena, May 14, 2008
    #1
    1. Advertisements

  2. Athena

    Andy Pope Guest

    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

    Athena wrote:
    > Hello,
    >
    > I need to save some Excel Graphs as jpg files. How can I do it?
    >
    > Thank you.
    >
    > Athena


    --

    Andy Pope, Microsoft MVP - Excel
    http://www.andypope.info
     
    Andy Pope, May 14, 2008
    #2
    1. Advertisements

  3. Athena

    Athena Guest

    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

    "Andy Pope" <> wrote in message
    news:...
    > 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
    >
    > Athena wrote:
    >> Hello,
    >>
    >> I need to save some Excel Graphs as jpg files. How can I do it?
    >>
    >> Thank you.
    >>
    >> Athena

    >
    > --
    >
    > Andy Pope, Microsoft MVP - Excel
    > http://www.andypope.info
     
    Athena, May 14, 2008
    #3
  4. Athena

    Jon Peltier Guest

    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" <> wrote in message
    news:...
    > 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
    >
    > "Andy Pope" <> wrote in message
    > news:...
    >> 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
    >>
    >> Athena wrote:
    >>> Hello,
    >>>
    >>> I need to save some Excel Graphs as jpg files. How can I do it?
    >>>
    >>> Thank you.
    >>>
    >>> Athena

    >>
    >> --
    >>
    >> Andy Pope, Microsoft MVP - Excel
    >> http://www.andypope.info

    >
     
    Jon Peltier, May 15, 2008
    #4
  5. Athena

    Athena Guest

    Jon,

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

    Athena

    "Jon Peltier" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    >> 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
    >>
    >> "Andy Pope" <> wrote in message
    >> news:...
    >>> 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
    >>>
    >>> Athena wrote:
    >>>> Hello,
    >>>>
    >>>> I need to save some Excel Graphs as jpg files. How can I do it?
    >>>>
    >>>> Thank you.
    >>>>
    >>>> Athena
    >>>
    >>> --
    >>>
    >>> Andy Pope, Microsoft MVP - Excel
    >>> http://www.andypope.info

    >>

    >
    >
     
    Athena, May 16, 2008
    #5
  6. Athena

    tprtaks

    Joined:
    Jul 6, 2010
    Messages:
    1
    Likes Received:
    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.
     
    tprtaks, Jul 6, 2010
    #6
  7. Athena

    rfengr_1

    Joined:
    Apr 2, 2011
    Messages:
    3
    Likes Received:
    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
     
    rfengr_1, Apr 2, 2011
    #7
  8. Athena

    Bryang0906

    Joined:
    May 6, 2011
    Messages:
    1
    Likes Received:
    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!
     
    Bryang0906, May 6, 2011
    #8
  9. Athena

    rfengr_1

    Joined:
    Apr 2, 2011
    Messages:
    3
    Likes Received:
    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
     
    rfengr_1, May 6, 2011
    #9
  10. Athena

    Dezy

    Joined:
    May 10, 2011
    Messages:
    11
    Likes Received:
    0
    Location:
    Gujarat

    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
     
    Dezy, May 10, 2011
    #10
  11. Athena

    jgalins

    Joined:
    May 17, 2011
    Messages:
    1
    Likes Received:
    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.
     
    jgalins, May 17, 2011
    #11
  12. Athena

    Dezy

    Joined:
    May 10, 2011
    Messages:
    11
    Likes Received:
    0
    Location:
    Gujarat
    Ya sure i would try and tell u now
     
    Dezy, May 28, 2011
    #12
  13. Athena

    greeves1

    Joined:
    Feb 14, 2012
    Messages:
    1
    Likes Received:
    0


    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.
     
    greeves1, Feb 14, 2012
    #13
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. LLC

    Half Bar Graph / Half Stack Graph ??

    LLC, Jul 8, 2004, in forum: Microsoft Excel Charting
    Replies:
    2
    Views:
    1,103
  2. Guest
    Replies:
    1
    Views:
    2,119
    Tushar Mehta
    Jan 3, 2006
  3. Guest

    Add export graph function to Excel (e.g. jpg, eps, wmf)

    Guest, Jan 23, 2006, in forum: Microsoft Excel Charting
    Replies:
    2
    Views:
    693
    Debra Dalgleish
    Jan 23, 2006
  4. Guest
    Replies:
    3
    Views:
    311
    Jon Peltier
    Jul 9, 2007
  5. Philippe

    How can I save an graph as an Excel chart with Excel 2007?

    Philippe, Apr 7, 2009, in forum: Microsoft Excel Charting
    Replies:
    0
    Views:
    597
    Philippe
    Apr 7, 2009
Loading...

Share This Page