• Export chart as JPG options (2000)

    Author
    Topic
    #407121

    I want to export an Excel chart image as a JPG. I can do this easily with the following code:

    Worksheets("Sheet1").ChartObjects(1) _
        .Chart.Export _
            Filename:="current_sales.jpg", FilterName:="JPG"
    

    This works a treat.
    My problem is, I want to be able to tweak the JPG save quality. If I use the Interactive:=True option which should ‘display the dialog box that contains the filter-specific options’, no dialog box is displayed (and anyway, even if it was, I’d want to control those properties programmatically).
    Does anyone know how I can send that value to the filter?
    Perhaps the normal chart-to-jpg filter doesn’t support any options. Does anyone know of other filters I could use that would achieve this?
    Thanks in advance for all your help.
    Peter

    Viewing 1 reply thread
    Author
    Replies
    • #849227

      I would try exporting to .png format instead. For standard charts, you will get better quality at lower file size than .jpg. A.gif will probably also be better than .jpg.

      • #849574

        True, PNG or GIF would be better for a real chart.
        Trick is, I’m using the chart export to convert a BMP image to JPG. The easiest way for me to do this from VBA is to create an empty Excel chart, insert a picture (a photograph) into the empty-chart wrapper and then export the chart. It works a treat. Because what I’m really exporting is a photo, JPG’s probably the best choice.
        But I want to be able to tune the compression!
        Peter

        • #849609

          2JPEG is an application with a command-line interface that can be called from another application to create .jpg files; it is fully configurable with command line options. Not cheap, though.

          • #850033

            You can also try Irfan View. Free (for non commercial use; $10 for single user commercial license) and can be run from the command line – in VBA create a text batchfile specifying the control commands and use the shell() command to run it.

          • #850034

            You can also try Irfan View. Free (for non commercial use; $10 for single user commercial license) and can be run from the command line – in VBA create a text batchfile specifying the control commands and use the shell() command to run it.

        • #849610

          2JPEG is an application with a command-line interface that can be called from another application to create .jpg files; it is fully configurable with command line options. Not cheap, though.

      • #849575

        True, PNG or GIF would be better for a real chart.
        Trick is, I’m using the chart export to convert a BMP image to JPG. The easiest way for me to do this from VBA is to create an empty Excel chart, insert a picture (a photograph) into the empty-chart wrapper and then export the chart. It works a treat. Because what I’m really exporting is a photo, JPG’s probably the best choice.
        But I want to be able to tune the compression!
        Peter

    • #849228

      I would try exporting to .png format instead. For standard charts, you will get better quality at lower file size than .jpg. A.gif will probably also be better than .jpg.

    Viewing 1 reply thread
    Reply To: Reply #850034 in Export chart as JPG options (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel