MS chart not exporting as picture

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • munkee
    Contributor
    • Feb 2010
    • 374

    MS chart not exporting as picture

    I am using the following code to export my graph as a picture:

    Code:
    Private Sub btnPrintTheGraph_Click()
    On Error GoTo cmdExportGraph_Click_Err
        Dim strErrMsg As String 'For Error Handling
        Dim strFileName As String
        Dim strfilter As String
        Dim lngFlags As Long
        Dim curdated As String
        
        curdated = Format(Now(), "dd-mm-yyyy")
        
        
    
        strFileName = ahtCommonFileOpenSave(Flags:=lngFlags, InitialDir:="", _
            Filter:="PNG Files (*.png)", FilterIndex:=1, DefaultExt:="png", FileName:="MyGraph " & curdated, DialogTitle:= _
            "Save the Graph", OpenFile:=False)
    
    Me.ChartSpace.ExportPicture strFileName, , 800, 600
    
    
    MsgBox vbCrLf & "The Chart " & strFileName & " has been exported", _
            vbInformation + vbOKOnly, "Chart Exported :"
    
    cmdExportGraph_Click_Exit:
        Exit Sub
    
    cmdExportGraph_Click_Err:
    MsgBox Err.Description & Err.Number
    
                Resume cmdExportGraph_Click_Exit
    End Sub

    However I get the following error:

    Code:
    The expression you entered referes to an object that is closed or doesn't exist - 2467
    I have attached the setup of my form and the properties of the graph.

    Thanks for any help!


    Edit:

    The attachment has shrunk the image so here is a link;

    Attached Files
Working...