• Export Chart to file (2002/SP3)

    Author
    Topic
    #455479

    I have an embedded chart object in my worksheet. I’m wrote a code which will export the chart to a GIF file, but it comes with an Run-time error ’91’ in line 7. How can I fix this?

    Private Sub SaveGIF_Click()
    Dim chtChart As ChartObject
    Dim FileName
    FileName = “Temperature.gif”
    FileName = Application.GetSaveAsFilename(FileName)
    If FileName False Then
    chtChart.Chart(“TemperatureChart”).ExportPicture FileName, Width:=320, Height:=240
    End If
    End Sub

    Viewing 0 reply threads
    Author
    Replies
    • #1134071

      Your code makes little sense.

      1) You declare a variable chtChart but don’t assign it a value, so it is empty when you try to export it.
      2) chtChart.Chart(“TemperatureChart”) is meaningless.
      3) ExportPicture is not a method of any object in Excel.

      Try this:

      Set chtChart = ActiveSheet.ChartObjects(“TemperatureChart”)
      chtChart.Chart.Export FileName, “GIF”

    Viewing 0 reply threads
    Reply To: Export Chart to file (2002/SP3)

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

    Your information: