Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

graph memory leak

Status
Not open for further replies.

hitoshi

Programmer
Jul 26, 2004
8
CA
Hey,

I am pasting a lot of data from excel to powerpoint, here is a code fragment:

Code:
Sub adjustData()
'
' This sub changes the chart data to the relevant excel informaiton
'

    Dim oGraph As Object
    Dim oPPTShape As PowerPoint.Shape
    Dim j As Integer
    On Error GoTo xxx
    Set oPPTShape = ActivePresentation.Slides(i + 1).Shapes(yq + 2)
    If oPPTShape.Type = msoEmbeddedOLEObject Then
       If oPPTShape.OLEFormat.ProgID = "MSGraph.Chart.8" Then
           Set oGraph = oPPTShape.OLEFormat.Object
           oGraph.Application.dataSheet.Range("00").Paste False 'true
       End If
    End If
    Set oGraph = Nothing
    set oPPTShape = Nothing
    Exit Sub
xxx:     Debug.Print "there was an error"
End Sub

This will be called once for every slide.

The problem is when you paste the data, if u pause your program you can see that an instance of Graph9.exe is running in the Task Manager. Or in this case, there is an instance for every slide, about 20 instances, and they all take up a remarkable amount of system resources.

I figured the,
Code:
    Set oGraph = Nothing
    Set oPPTShape = Nothing

would free the memory, but it does not. When execution is complete, the instances terminate. But while the code is running this makes my old computer at home crash.

Any help would be great.

-Greg
 
Actually, on this computer, Graph9.exe never exists. Do you know an API call to terminate a program?

-greg
 
Actually, I figured it out myself.

Here's my solution for anyone who is interested:

You need to "activate" the chart by doing the following:
Code:
    ActivePresentation.Slides(i + 1).Shapes(yq + 2).Select
    ActiveWindow.Selection.ShapeRange.OLEFormat.DoVerb Index:=1
    ActiveWindow.Selection.SlideRange.Shapes("Object 5").Select
    ActiveWindow.Selection.Unselect
    
    Set oGraph = Nothing
    Set oPPTShape = Nothing

Hurray! I get a gold star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top